This is the mpc Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:07:03 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
mpc
Monadic Parser Combinators for Common Lisp. MPC tries to be simple and practical while being powerful, well documented and fairly performant. A friendly fork of Drew Crampsies _Smug_ library.
Max Rottenkolber <max@mr.gy>
GNU Affero General Public License
packages.lisp
(file).
input.lisp
(file).
mpc.lisp
(file).
characters.lisp
(file).
numerals.lisp
(file).
error.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
mpc/mpc.asd
mpc/packages.lisp
mpc/input.lisp
mpc/mpc.lisp
mpc/characters.lisp
mpc/numerals.lisp
mpc/error.lisp
mpc/input.lisp
packages.lisp
(file).
mpc
(system).
array-index
(type).
copy-index
(function).
copy-index-array
(function).
copy-index-list
(function).
copy-index-simple-array
(function).
copy-index-simple-string
(function).
index
(structure).
index-array
(structure).
index-array-array
(reader).
index-array-p
(function).
index-array-position
(function).
index-list
(structure).
index-list-list
(reader).
index-list-p
(function).
index-list-position
(function).
index-p
(function).
index-position
(reader).
index-simple-array
(structure).
index-simple-array-array
(function).
index-simple-array-p
(function).
index-simple-array-position
(function).
index-simple-string
(structure).
index-simple-string-array
(function).
index-simple-string-p
(function).
index-simple-string-position
(function).
input-element-type
(generic function).
input-empty-p
(generic function).
input-first
(generic function).
input-position
(generic function).
input-rest
(generic function).
make-index
(function).
make-index-array
(function).
make-index-list
(function).
make-index-simple-array
(function).
make-index-simple-string
(function).
make-input
(generic function).
mpc/mpc.lisp
packages.lisp
(file).
input.lisp
(file).
mpc
(system).
=and
(function).
=at-least
(function).
=bind
(function).
=end-of-input
(function).
=eql
(function).
=exactly
(function).
=fail
(macro).
=funcall
(function).
=if
(function).
=item
(function).
=let*
(macro).
=list
(function).
=maybe
(function).
=none-of
(function).
=not
(function).
=one-of
(function).
=one-or-more
(function).
=one-to
(function).
=or
(function).
=plus
(function).
=prog1
(function).
=prog2
(function).
=range
(function).
=result
(function).
=satisfies
(function).
=unless
(function).
=when
(function).
=zero-or-more
(function).
=zero-to
(function).
run
(function).
*input-at-run*
(special variable).
*input-during-fail*
(special variable).
=binary-and
(function).
mpc/characters.lisp
packages.lisp
(file).
mpc.lisp
(file).
mpc
(system).
*whitespace*
(special variable).
=character
(function).
=line
(function).
=newline
(function).
=skip-whitespace
(function).
=string
(function).
=string-of
(function).
=whitespace
(function).
mpc/numerals.lisp
packages.lisp
(file).
mpc.lisp
(file).
characters.lisp
(file).
mpc
(system).
=digit
(function).
=integer-number
(function).
=natural-number
(function).
mpc/error.lisp
packages.lisp
(file).
mpc.lisp
(file).
mpc
(system).
=handler-case
(macro).
=restart-case
(macro).
get-input-position
(function).
cases-to-parser-cases
(function).
parse-line-position
(function).
Packages are listed by definition order.
mpc.characters
This package includes parsers specialised for character input. Covered are case sensitivity, strings, whitespace and lines.
common-lisp
.
mpc
.
*whitespace*
(special variable).
=character
(function).
=line
(function).
=newline
(function).
=skip-whitespace
(function).
=string
(function).
=string-of
(function).
=whitespace
(function).
mpc
Monadic parser combinators. This package contains general purpose parser combinators of varying sophistication. It also contains the {run} entry function and a handful of macros that integrate parser combinators into the Common Lisp condition system. Functions starting with the {=}-prefix construct _parsers_. Their documentation is written from the perspective of the resulting parser. Refer to the [MPC Manual](manual.html) for a general introduction.
common-lisp
.
=and
(function).
=at-least
(function).
=bind
(function).
=end-of-input
(function).
=eql
(function).
=exactly
(function).
=fail
(macro).
=funcall
(function).
=handler-case
(macro).
=if
(function).
=item
(function).
=let*
(macro).
=list
(function).
=maybe
(function).
=none-of
(function).
=not
(function).
=one-of
(function).
=one-or-more
(function).
=one-to
(function).
=or
(function).
=plus
(function).
=prog1
(function).
=prog2
(function).
=range
(function).
=restart-case
(macro).
=result
(function).
=satisfies
(function).
=unless
(function).
=when
(function).
=zero-or-more
(function).
=zero-to
(function).
get-input-position
(function).
run
(function).
*input-at-run*
(special variable).
*input-during-fail*
(special variable).
=binary-and
(function).
array-index
(type).
cases-to-parser-cases
(function).
copy-index
(function).
copy-index-array
(function).
copy-index-list
(function).
copy-index-simple-array
(function).
copy-index-simple-string
(function).
index
(structure).
index-array
(structure).
index-array-array
(reader).
index-array-p
(function).
index-array-position
(function).
index-list
(structure).
index-list-list
(reader).
index-list-p
(function).
index-list-position
(function).
index-p
(function).
index-position
(reader).
index-simple-array
(structure).
index-simple-array-array
(function).
index-simple-array-p
(function).
index-simple-array-position
(function).
index-simple-string
(structure).
index-simple-string-array
(function).
index-simple-string-p
(function).
index-simple-string-position
(function).
input-element-type
(generic function).
input-empty-p
(generic function).
input-first
(generic function).
input-position
(generic function).
input-rest
(generic function).
make-index
(function).
make-index-array
(function).
make-index-list
(function).
make-index-simple-array
(function).
make-index-simple-string
(function).
make-input
(generic function).
parse-line-position
(function).
mpc.numerals
This package includes parsers for string numerals.
Covered are single digits, natural numbers and signed integers with
arbitrary radixes.
common-lisp
.
mpc
.
mpc.characters
.
=digit
(function).
=integer-number
(function).
=natural-number
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
*Value Type:*
a _list_ of _characters_.
*Description:*
The _value_ of {*whitespace*} is a _list_ of _characters_ considered to be _whitespace characters_.
*Arguments and Values:*
_handling_—_forms_ to run when the parser is invoked.
*Description:*
{=fail} always fails. If supplied, the _handling forms_ will be run when {=fail} is applied. The _handling forms_ may call {get-input-position}.
*Arguments and Values:*
_parser_—a _parser_.
_handlers_—handler clauses for {handler-case}.
*Description:*
{=handler-case} establishes _handlers_ as if by {handler-case} before applying _parser_ to the input. _Handlers_ must return _parsers_. If _parser_ signals an _error_ matched by a _handler_, the _parser_ returned by the _handler_ will be applied to the input.
mpc
.
_bindings_::= {(}{{}{(}_symbol_ _parser_{)}{\}}\*{)}
*Arguments and Values:*
_forms_—_forms_ of which the last _form_ must return a _parser_.
_symbol_—a _symbol_.
_parser_—a _form_ whose result is a _parser_.
*Description:*
{=let*} applies the _parsers_ in _bindings_ as if by {=and} and evaluates _forms_ in an implicit {let} environment where the results are bound to the _symbols_ in _bindings_. Finally, {=let*} applies the parser returned by the last _form_.
*Arguments and Values:*
_parser_—a _parser_.
_restarts_—restart clauses for {restart-case}.
*Description:*
{=restart-case} establishes _restarts_ as if by {restart-case} before applying _parser_ to the input. _Restarts_ must return _parsers_. If _parser_ signals an _error_ matched by a _restart_, the _parser_ returned by the _restart_ will be applied to the input.
mpc
.
*Arguments and Values:*
_parsers_—_parsers_.
*Description:*
{=and} applies _parsers_ sequentially. If all _parsers_ succeed, {=and} succeeds with the last _parser_’s result. Otherwise {=and} fails.
*Arguments and Values:*
_n_, _limit_—_bounding index designators_. The default for _limit_ is
{nil}.
_parser_—a _parser_.
*Description:*
{=at-least} applies _parser_ repeatedly until it fails and succeeds with a list of the results unless _parser_ succeeded less than _n_ times or, if _limit_ is not {nil}, more than _limit_ times.
*Arguments and Values:*
_parser_—a _parser_.
_make-parser_—a _function designator_ for a one-argument _function_
which returns a _parser_.
*Description:*
{=bind} applies _parser_ to the input. For each resulting {(value . input)} pair {=bind} calls _make-parser_ with each _value_ and applies the resulting parser to each _input_. {=bind} succeeds with the concatenated results or fails if _parser_ fails.
*Arguments and Values:*
_character_—a _character_.
_case-sensitive-p_—a _generalized boolean_. The default is _true_.
*Description:*
{=character} consumes the next item and succeeds with that item as its result if the item is equal to _character_. {=character} is case sensitive unless _case-sensitive-p_ is _false_.
*Arguments and Values:*
_radix_—a _number_ of _type_ {(integer 2 36)}. The default is {10}.
*Description:*
{=digit} consumes the next item and succeeds with that item as its result if the next item is a digit _character_ in the specified _radix_.
*Description:*
{=end-of-input} succeeds only if the input is empty.
*Arguments and Values:*
_x_—an _object_.
*Description:*
{=eql} consumes the next item and succeeds with that item as its result if the item is {eql} to _object_.
*Arguments and Values:*
_n_—an non-negative _integer_.
_parser_—a _parser_.
*Description:*
{=exactly} applies _parser_ repeatedly until it fails and succeeds with a list of the results unless _parser_ succeeded not exactly _n_ times.
*Arguments and Values:*
_parser_—a _parser_.
_function_—a _function designator_.
*Description:*
{=funcall} applies _parser_. If successful, {=funcall} applies _function_ on its result and succeeds with the return value.
*Arguments and Values:*
_test-parser_—a _parser_.
_then-parser_—a _parser_.
_else-parser_—a _parser_. The default is {(=fail)}.
*Description:*
{=if} applies _then-parser_ if _test-parser_ would succeed and _else-parser_ otherwise. Note that _test-parser_ is not actually applied to the input.
*Arguments and Values:*
_radix_—a _number_ of _type_ {(integer 2 36)}. The default is {10}.
*Description:*
{=integer-number} consumes a signed non-empty sequence of digit
_characters_ in the specified _radix_ and succeeds with the _integer_
represented by that sequence. The leading sign is optional and can be
{#\\+} and {#\\-} for positive and negative values
respectively. The default is a positive value.
*Description:*
{=item} consumes the next item and succeeds with that item as its result unless the input is empty.
*Arguments and Values:*
_keep-newline-p_—a _generalized boolean_. The default is _false_.
*Description:*
{=line} consumes a sequence of zero or more _characters_ terminated by a {#\\Newline} _character_ and succeeds with the _characters_ coerced to a _string_. The terminating {#\\Newline} _character_ is not included in the result unless _keep-newline-p_ is _true_.
*Arguments and Values:*
_parsers_—_parsers_.
*Description:*
{=list} applies _parsers_ sequentially. If all _parsers_ succeed, {=list} succeeds with a list of their results. Otherwise {=list} fails.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=maybe} applies _parser_. If _parser_ succeeds {=maybe} will succeed with its result, otherwise it will succeed with {nil}.
*Arguments and Values:*
_radix_—a _number_ of _type_ {(integer 2 36)}. The default is {10}.
*Description:*
{=natural-number} consumes a non-empty sequence of digit _characters_ in the specified _radix_ and succeeds with the natural _number_ represented by that sequence.
*Description:*
{=newline} consumes the next item and succeeds with that item as its result if the item is the {#\\Newline} _character_.
*Arguments and Values:*
_list_—a _list_ of _objects_.
*Description:*
{=none-of} consumes the next item and succeeds with that item as its result unless the item is {eql} to one of the _objects_ in _list_.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=not} consumes the next item and succeeds with that item as its result if _parser_ would fail. E.g. it negates _parser_. Note that _parser_ is not actually applied to the input.
*Arguments and Values:*
_list_—a _list_ of _objects_.
*Description:*
{=one-of} consumes the next item and succeeds with that item as its result if the item is {eql} to any _object_ in _list_.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=one-or-more} applies _parser_ repeatedly until it fails and succeeds with a list of the results if _parser_ succeeded at least one time.
*Arguments and Values:*
_n_—a positive _integer_.
_parser_—a _parser_.
*Description:*
{=one-to} applies _parser_ repeatedly until it fails and succeeds with a list of the results unless _parser_ succeeded less than once or more than _n_ times.
*Arguments and Values:*
_parsers_—_parsers_.
*Description:*
{=or} applies _parsers_ until one _parser_ succeeds, in which case it succeeds with the result of that _parser_. If no _parser_ succeeds {=or} fails.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=plus} is the non-deterministic choice combinator. It applies _parsers_ to input and succeeds with the result of every successful _parser_. {=plus} fails if every _parser_ fails.
*Arguments and Values:*
_parser_—a _parser_.
_parsers_—_parsers_.
*Description:*
{=prog1} applies _parser_ and _parsers_ sequentially. If they all succeed, {=prog1} succeeds with _parser_’s result. Otherwise {=prog1} fails.
*Arguments and Values:*
_parser1_—a _parser_.
_parser2_—a _parser_.
_parsers_—_parsers_.
*Description:*
{=prog2} applies _parser1_, _parser2_ and _parsers_ sequentially. If they all succeed, {=prog2} succeeds with _parser2_’s result. Otherwise {=prog2} fails.
*Arguments and Values:*
_from_—an _object_.
_to_—an _object_.
_parser_—a _parser_. The default is {(=item)}.
_predicate_—a _function designator_ for a three-argument predicate
_function_. The default is {char<=}.
*Description:*
{=range} applies _parser_ and, if it succeeds, applies _predicate_ to _from_, its results and _to_. {=range} succeeds with the result of _parser_ if _predicate_ is _true_ and fails otherwise.
*Arguments and Values:*
_value_—an _object_.
*Description:*
{=result} always succeeds with _value_ as its result.
*Arguments and Values:*
_predicate_—a _function designator_ for a one-argument predicate
_function_.
*Description:*
{=satisfies} consumes the next item and succeeds with that item as its result if the result satisfies _predicate_.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=skip-whitespace} consumes a sequence of zero or more items which are members of {*whitespace*} and then applies _parser_ and, if successful, succeeds with its result.
*Arguments and Values:*
_string_—a _string_.
_case-sensitive-p_—a _generalized boolean_. The default is _true_.
*Description:*
{=string} consumes a non-empty sequence of _characters_ and succeeds with the _character sequence_ coerced to a _string_ if the result is equal to _sting_. {=string} is case sensitive unless _case-sensitive-p_ is _false_.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=string-of} repeatedly applies _parser_ to the input and succeeds with the resulting _character sequence_ coerced to a _string_. {=string-of} fails unless _parser_ succeeds at least once.
*Arguments and Values:*
_test-parser_—a _parser_.
_parsers_—_parsers_.
*Description:*
{=unless} applies _parsers_ as if by {=and} if _test-parser_ would fail. Note that _test-parser_ is not actually applied to the input.
*Arguments and Values:*
_test-parser_—a _parser_.
_parsers_—_parsers_.
*Description:*
{=when} applies _parsers_ as if by {=and} if _test-parser_ would succeed. Note that _test-parser_ is not actually applied to the input.
*Description:*
{=whitespace} consumes the next item and succeeds with that item as its result if the item is a member of {*whitespace*}.
*Arguments and Values:*
_parser_—a _parser_.
*Description:*
{=zero-or-more} applies _parser_ repeatedly until it fails and succeeds with a list of the results.
*Arguments and Values:*
_n_—an non-negative _integer_.
_parser_—a _parser_.
*Description:*
{=zero-to} applies _parser_ repeatedly until it fails and succeeds with a list of the results unless _parser_ succeeded more than _n_ times.
→ _position_
→ _position_, _line_, _column_
*Arguments and Values:*
_position_, _column_—non-negative _integers_.
_line_—a positive _integer_.
*Description:*
{get-input-position} returns the number of items read from the
input. Additionally, _line_ and _column_ positions are returned if the
input’s _element type_ is {character}. Lines are counted starting at 1
while columns are counted starting from 0.
{get-input-position} may only be called from within the body of
{=fail}, the handlers of {=handler-case} or the restarts of
{=restart-case}.
*Exceptional Situations:*
{get-input-position} signals an _error_ of _type_ {simple-error} unless called within {=fail}, {=handler-case} or {=restart-case}.
mpc
.
*Arguments and Values:*
_parser_—a _parser_.
_input-source_—an _array_, an _input stream_ or a _list_.
_result_—a _function designator_ to a one-argument _function_. The
default is {caar}.
*Description:*
{run} applies _parser_ to _input-source_ and returns the result of
calling the _result_ function on the resulting list of
{(value . input)} pairs.
=BIND PARSER-A and PARSER-B and fail if any of those fails. Otherwise return the result of PARSER-B.
Utility macro function for =HANDLER-CASE and =RESTART-CASE.
mpc
.
Parses line position of POSITION in INPUT.
mpc
.
Returns element type of {INPUT}.
mpc
.
index-array
)) ¶Predicate to test if {INPUT} is empty.
mpc
.
index-array
)) ¶index-list
)) ¶Returns first element of {INPUT}.
mpc
.
index-simple-string
)) ¶index-simple-array
)) ¶index-array
)) ¶index-list
)) ¶Returns index position of {INPUT}.
mpc
.
Returns {INPUT} with its first element stripped.
mpc
.
index-simple-string
)) ¶index-simple-array
)) ¶index-array
)) ¶index-list
)) ¶Returns input object for {SOURCE}.
Generic index.
Index array.
Index list.
Index simple array.
mpc
.
Index simple string.
mpc
.
Jump to: | =
C F G I M P R |
---|
Jump to: | =
C F G I M P R |
---|
Jump to: | *
A L P S |
---|
Jump to: | *
A L P S |
---|
Jump to: | A C E F I M N P S T |
---|
Jump to: | A C E F I M N P S T |
---|