The parseq Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The parseq Reference Manual

This is the parseq Reference Manual, version 0.5.0, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:22:45 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

PARSEQ

Description

Parseq (pronounced parsec) is a parsing library for common lisp. It can be used for parsing lisp's sequences types: strings, vectors (e.g. binary data) and lists. Furthermore, parseq is able to parse nested structures such as trees (e.g. lists of lists, lists of vectors, vectors of strings).

Parseq uses parsing expression grammars (PEG) that can be defined through a simple interface. Extensions to the standard parsing expressions are available. Parsing expressions can be parameterised and made context aware. Additionally, the definition of each parsing expression allows the arbitrary transformation of the parsing tree.

The library is inspired by Esrap and uses a very similar interface. No code is shared between the two projects, however. The features of Esrap are are mostly included in parseq and complemented with additional, orthogonal features. Any resemblance to esrap-liquid is merely coincidental.

The library is still under development. This means that some features are not yet implemented and that the interface and behaviour may change in the future. See the warnings below.

Features

Parseq provides the following features:

Basic usage

First, define a set of grammar rules:

(defrule foo () "foo")
(defrule bar () "bar")
(defrule foobar () (and foo bar))

The first argument to (defrule ...) is the nonterminal symbol that will represent the rule. These symbols use a different namespace from everything else. The second argument is a list of parameters that the rule takes (none in this example). The third argument specifies the definition of the nonterminal symbol. After the third argument, multiple processing options can be listed.

In this example, the nonterminal foo requires the parsing of the string "foo". The rule foobar combines the two rules foo and bar to match the string "foobar", the list ("foo" "bar") or the vector #("foo" "bar"). The above example could alternatively be stated as

(defrule foobar () (and "foo" "bar"))

thus not requiring the rules foo and bar.

Parsing is initiated by calling

(parseq 'foobar sequence)

which will return the list ("foo" "bar") as well as T if sequence is one of "foobar", ("foo" "bar") and #("foo" "bar"). If parsing is not successful, NIL is returned. The first argument to (parseq ...) is a nonterminal symbol defined through defrule. Note that the symbol must be quoted. The second argument is the sequence that should be parsed. There are optional keyword parameters to (parseq ...):

This concludes the basic usage of the library. Almost everything is done through defrule and parseq. There are some extra arguments, however, that are explained below.

Installation

Parseq is available with quicklisp. You can run

(ql:quickload :parseq)

in the REPL to download, install and load it. To access the symbols from the package without the parseq: prefix you can type

(use-package :parseq)

Alternatively, the system is can be downloaded/cloned from GitHub. The master branch will always point to the latest release. If the system can be found through ASDF, the system can be loaded by typing the following expressions in the REPL:

(require :asdf)                ; unless already loaded
(asdf:load-system :parseq)
(use-package :parseq)          ; optional

Terminals

Terminals (tokens) are the objects that actually appear in the parsed sequence. The following types are item classes:

Literal values can be specified to match specific items or subsequences in the sequence being parsed:

Terminal expressions allow for mor elaborate specifications:

More terminals may be available in later versions of parseq.

Nonterminals

Nonterminal symbols represent parsing expressions that consist of terminals and/or other nonterminals. They can be defined using the defrule macro.

Standard expressions

These are the standard combinations of a parsing expression grammar.

Sequence

(and subexpression ...)

The expression succeeds for a sequence if all subexpressions succeed in the given order. It produces a list of the subexpression results. On success, the amount of input consumed is determined by the subexpressions.

Ordered choice

(or subexpression ...)

The subexpressions are tried in the given order and the result of the first one that succeeds is accepted. It produces the result of the succeeding subexpression. The amount of input consumed depends on the subexpression. If none of the subexpressions match, the expression fails.

Greedy repetition

(* subexpression)

Tries subexpression consecutively as many times as possible. This expression always succeeds because zero repetitions are allowed. A list of the succeeding matches is returned. The amount of input consumed depends on the subexpression and the number of times it matches.

Greedy positive repetition

(+ subexpression)

Like (* subexpression), but at least one repetition is required.

Optional

(? subexpression)

Consumes and returns whatever subexpression consumes if it succeeds. This operation is greedy which means that if the subexpression matches, it will consume the corresponding input. If the subexpression fails, no input is consumed and NIL returned.

Followed-by predicate

(& subexpression)

Succeeds, if subexpression succeeds, but consumes no input. The result of the subexpression is returned.

Not-followed-by predicate

(! subexpression)

Succeeds if subexpression does not succeed. This expression consumes no input. When successful, the next sequence item is returned.

Extended expressions

For convenience, the standard expressions are extended by the following combination methods:

Repetition

(rep 5 subexpression)
(rep (0 5) subexpression)
(rep (2 5) subexpression)
(rep (2 NIL) subexpression)

Succeeds, if subexpression matches exactly 5 times, up to 5 times, between 2 and 5 times, or at least 2 times, respectively. Returns a list of the successful results.

The following abbreviations are allowed for repetitions:

| Abbreviation | Long notation | Meaning | | ------------ |:-------------:| ------------------- | | 3 | (3 3) | Exactly 3 times | | (3) | (0 3) | Up to 3 times | | * | (0 NIL) | Any number of times | | + | (1 NIL) | At least once | | ? | (0 1) | Zero times or once |

Negation

(not subexpression)

Succeeds, if the subexpression does not succeed. When that happens, the rule consumes exactly one item in the sequence and returns it.

Sequence (unordered)

(and~ subexpression ...)

The expression succeeds for a sequence if all subexpressions succeed, in any order. Note that the first subexpression in the list that matches a sequence item will be used. The expression produces a list of the subexpression results (in the order in which they are listed in the rule definition) and consumes whatever the subexpressions consume.

An expression like (and~ 'a 'b 'c 'd) is actually equivalent to

(or (and 'a (or (and 'b (or (and 'c 'd) (and 'd 'c)))
                (and 'c (or (and 'b 'd) (and 'd 'b)))
                (and 'd (or (and 'b 'c) (and 'c 'b)))))
    (and 'b (or (and 'a (or (and 'c 'd) (and 'd 'c)))
                (and 'c (or (and 'a 'd) (and 'd 'a)))
                (and 'd (or (and 'a 'c) (and 'c 'a)))))
    (and 'c (or (and 'a (or (and 'b 'd) (and 'd 'b)))
                (and 'b (or (and 'a 'd) (and 'd 'a)))
                (and 'd (or (and 'a 'b) (and 'b 'a)))))
    (and 'd (or (and 'a (or (and 'b 'c) (and 'c 'b)))
                (and 'b (or (and 'a 'c) (and 'c 'a)))
                (and 'c (or (and 'a 'b) (and 'b 'a))))))

There is a variant of and~ that is more flexible:

(and~~ (1 2 (1) (2 3) (4 nil) ...) subexpr-1 subexpr-2 subexpr-3 subexpr-4 subexpr-5 ...)

The first argument to and~~ specifies how may times each subexpression is allowed to be repeated. (See the rep operator above for a list of abbreviations.) In this example, the first subexpression is required exactly once, the second one exactly twice, the third zero times or once, the fourth between 2 and 3 times and the fifth at least 4 times. During parsing, the prioritisation of the subexpressions that are still applicable is from left to right. The result is a list of lists: The list is ordered in the same way that subexpressions are given in the rule definition. The n-th list within the list contains the results of the n-th subexpression in the order in which they are found in the parsed expression.

Nesting

(list subexpr-1 subexpr-2 ...)
(string subexpr-1 subexpr-2 ...)
(vector subexpr-1 subexpr-2 ...)

Succeeds if the current item in the sequence is a list/string/vector and its content matches the subexpressions in sequence. Returns a list enclosing the subexpression results.

Rule parameters

Often, rules are similar to each other. For example

(defrule html-a () "<a>")
(defrule html-b () "<b>")
(defrule html-span () <span>")

share the same pattern. In parseq, this can be generalised with

(defrule html-tag (name) (and "<" name ">")

and used in parsing expressions as (html-tag "a") instead of having to define each rule separately. The parameters can also be used in the processing options (see below). Note, however, that since the rule parameter is unknown at compile time, a runtime dispatch will need to be performed on the parameter type. In the current implementation, only literal terminals and nonterminals are supported as part of the parsing expression. This will likely change in the future.

It is possible to pass multiple paramters, keywords etc. The full syntax of lambda lists is allowed.

Processing options

There are several options that can be specified for each rule definition. The options can have several effects which are described below.

Transformation of parse results

The result from a parsing rule can be processed. Example:

(defrule abcde () (and (and 'a 'b) 'c (and 'd 'e)))
(parseq 'abcde '(a b c d e))

would normally return ((a b) c (d e)). To process the result, options can be specified in the call to defrule. For example, if you want the resulting list flattened, the rule can be altered to

(defrule abcde () (and (and 'a 'b) 'c (and 'd 'e)) (:flatten))

such that parsing (a b c d e) yields (a b c d e) instead of ((a b) c (d e)).

You can specify how processing of the parsing result is done through multiple options (see below). Additional options (such as :test) do not affect the parse result, but have other effects. Note that the options are processed in sequence and the output of the previous option is input into the next option:

(defrule int+int^2 () (and number number) (:lambda (x y) (+ x y)) (:lambda (x) (expt x 2)))

This would return 25 when parsing the list (2 3).

Constant result

(:constant 1)

This options returns 1 (or whatever you specify) if the rule succeeds, irrespective of the parsing result.

Lambda / Destructure

(:lambda (a b (c d) &rest z) ...)
(:destructure (a b (c d) &rest z) ...)

Destructures the parsing result according to the specified lambda list and binds the given variables. The following forms can be used to process the result in whatever way. The new parsing result is given by what the last form returns. Note that :lambda and :destructure are actually synonyms.

Choose

(:choose 0 2 '(3 1))

Picks items from the parsing result using the given indices and returns them. For the parsing result (15 #\: 24 (#\: 57)) (which might be the parsing result of a time string), the above processing option would return (15 24 57). Non-existent items will result in NIL being returned for them.

Function

(:function #'+)

The parsing result is handed over to the function specified (here: +). Note that the lambda list of the given function has to match the items in the parsing result. The new parsing result is whatever the function returns.

Identity

(:identity t)

Returns the parsing result if the argument is not NIL and NIL otherwise.

Flatten

(:flatten)

Flattens the parsing result, i.e. (a (b c (d) e) (f g)) becomes (a b c d e f g).

String

(:string)

Flattens the parsing result and concatenates the list items to into a string, i.e. (#\a ("bc" (#\d) 'e) (#\f #x67)) becomes "abcdEfg". The items that can be concatenated are strings, characters, unsigned bytes and symbols.

Vector

(:vector)

Flattens the parsing result and converts the resulting list into a vector, i.e. (a (b c (d) e) (f g)) becomes #(a b c d e f g).

Parse result testing

These options do not affect the parse result, but can make the rule fail depending on their input. If a rule fails because of such an option, the processing of subsequent options is skipped.

Test

(:test (x) (and (numberp x) (> x 10)))

Like :lambda or :destructure, except that the return value of the function body is used as a predicate to determine whether the rule succeeds or not. Therefore, if the body of the test returns NIL, the rule fails. Otherwise, the unaltered result is returned. Note that the input to the test (function arguments) depends on the preceding processing options.

In the above example, the rule fails if the parse result is not an number greater than 10.

The following rule matches any symbol except baz:

(defrule not-baz () symbol (:not (x) (eql x 'baz)))

This is not possible with (not 'baz) because that would allow terminals other than symbols, e.g. 5 (which is not a symbol).

Reverse test

(:not (x) (and (numberp x) (> x 10)))

Same as :test, but logically inverted. In this example, the rule fails if the parse result is an number greater than 10.

Variables

Rules can bind variables that can be accessed/modified by subexpressions.

Variable binding

(:let a b (c 10))

Binds the specified variables (dynamically). Subexpressions (and subexpressions of subexpressions, etc) of the rule have access to these variables and can even modify them. In order to access the variables, the subexpressions have to declare them using :external (see below). If a subexpression binds the same variable with another :let, the previous binding is shadowed until the subexpression returns. For an example of variable usage, see the section 'Using context' below.

External bindings

(:external a b c)

Declares the specified variables. If the rule is called by a superior rule that binds these variables (using :let, see above), this rule can use and modify the variables. It is an error if a rule using external variables is called when the variables are unbound (i.e. the rule must be called as a subexpression to a rule defining the variables).

Packrat parsing

Packrat parsing can be enabled for a rule by using the (:packrat t) option. See the wiki page for more information.

Using context

Parsing in parseq can be made context aware using two methods.

Context through tests

A single rule can verify one part of its result against another. For instance, if a tag is a name followed by a type and a value, then the rule

(defrule tag () (and string symbol form) (:test (name type value) (eql (type-of value) type)))

will check whether the value is indeed of the specified type. Otherwise the rule will fail.

Context through variables

It is possible to make rules depend on the results of other rules. This can be achieved through external variable bindings that are introduced with (:let ...) and used with (:external ...).

Suppose the binary format of a file specifies that a string is stored as a byte indicating the length of the string followed by that number of characters. A set of rules for parsing this could be:

(defrule string () (and length chars) (:let len))
(defrule length () byte (:external len) (:lambda (x) (setf len x)))
(defrule chars () (rep len byte) (:external len))

External variables can also be used from within (:test ...) or (:not ...) or even the parse expression.

Rule tracing

Rules can be traced by calling

(trace-rule 'nonterminal-symbol)

which will print the information to standard output. With the keyword argument :recursive t, all rules called from within the given rule will be traced as well. Tracing can be turned off by calling

(untrace-rule 'nonterminal-symbol)

Namespaces

You can use local namespaces for nonterminal symbols:

(with-local-rules
  (defrule ...)
  (defrule ...)
  (parseq ...))

Within the body of with-local-rules new rules can be defined that will be invisible outside. Also, outside rules will be invisible within the body.

Instead of with-local-rules the macro with-saved-rules can be used:

(defrule a ...)
(defrule b ...)
(defrule ab () (and a b))
(with-saved-rules
  (defrule b ...)
  (parseq 'ab ...))
(parseq 'ab ...)

Within its body, rules from outside are still defined and can be redefined without affecting the outside. The rules from outside are saved before entering the body and restored when the body returns.

Upcoming features

These features may be implemented in the future:

Warnings

Please heed the following warnings:

Licence

Parseq is distributed with the GNU General Public License, version 2:

Copyright (C) 2017 Marco Rossini

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

You can also find the full licence online.

Questions/Bugs/Help/Requests/Feedback etc.

If you have questions regarding parseq, found any bugs, would like to offer help, have a feature request, give feedback etc., feel free to contact me through GitHub.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 parseq

Author

Marco Rossini

License

GPLv2

Description

A library for parsing sequences such as strings and lists using parsing expression grammars.

Version

0.5.0

Source

parseq.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 parseq.asd

Location

parseq.asd

Systems

parseq (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 parseq/package.lisp

Parent

parseq (system)

Location

package.lisp

Packages

parseq


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 parseq/conditions.lisp

Dependency

package.lisp (file)

Parent

parseq (system)

Location

conditions.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 parseq/utils.lisp

Dependency

conditions.lisp (file)

Parent

parseq (system)

Location

utils.lisp

Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.5 parseq/defrule.lisp

Dependency

utils.lisp (file)

Parent

parseq (system)

Location

defrule.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 parseq

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: defrule NAME LAMBDA-LIST EXPR &body OPTIONS
Package

parseq

Source

defrule.lisp (file)

Macro: with-local-rules &body BODY
Package

parseq

Source

defrule.lisp (file)

Macro: with-saved-rules &body BODY
Package

parseq

Source

defrule.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: parseq RULE SEQUENCE &key START END JUNK-ALLOWED PARSE-ERROR
Package

parseq

Source

defrule.lisp (file)

Function: trace-rule NAME &key RECURSIVE
Package

parseq

Source

defrule.lisp (file)

Function: untrace-rule NAME
Package

parseq

Source

defrule.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: parse-error-position CONDITION
Generic Function: (setf parse-error-position) NEW-VALUE CONDITION
Package

parseq

Methods
Method: parse-error-position (CONDITION parse-match-error)
Method: (setf parse-error-position) NEW-VALUE (CONDITION parse-match-error)
Source

conditions.lisp (file)

Generic Function: parse-error-terminals CONDITION
Generic Function: (setf parse-error-terminals) NEW-VALUE CONDITION
Package

parseq

Methods
Method: parse-error-terminals (CONDITION parse-match-error)
Method: (setf parse-error-terminals) NEW-VALUE (CONDITION parse-match-error)
Source

conditions.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Conditions

Condition: generic-parse-error ()

Generic parsing error

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

parseq-error (condition)

Direct subclasses
Condition: invalid-operation-error ()

Error condition for rule definitions where the usage of an operation is invalid.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

rule-definition-error (condition)

Condition: invalid-rule-error ()

Error condition for malformed calls to rules.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

runtime-error (condition)

Condition: invalid-terminal-error ()

Error condition for rule definitions where a terminal is unknown.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

rule-definition-error (condition)

Condition: left-recursion-error ()

Error condition for situations where left recursion is detected at runtime.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

runtime-error (condition)

Condition: parse-junk-error ()

Error condition for when the sequence is only partially parsed, leaving junk at the end.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

generic-parse-error (condition)

Condition: parse-match-error ()

Error condition for when the sequence does not match the parsing grammar rules.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

generic-parse-error (condition)

Direct methods
Direct slots
Slot: position
Initargs

:position

Readers

parse-error-position (generic function)

Writers

(setf parse-error-position) (generic function)

Slot: terminals
Initargs

:terminals

Initform

(quote nil)

Readers

parse-error-terminals (generic function)

Writers

(setf parse-error-terminals) (generic function)

Condition: parseq-error ()

Generic error for the parseq library

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

simple-error (condition)

Direct subclasses
Condition: processing-options-error ()

Error condition for rule definitions where a processing option is invalid.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

rule-definition-error (condition)

Condition: rule-definition-error ()

Generic error for rule definitions

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

parseq-error (condition)

Direct subclasses
Condition: runtime-error ()

Generic runtime error

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

parseq-error (condition)

Direct subclasses
Condition: unknown-rule-error ()

Error condition for situations where a rule definition is not found at runtime.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

runtime-error (condition)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *ascii-standard-chars*
Package

parseq

Source

defrule.lisp (file)

Special Variable: *packrat-table*
Package

parseq

Source

defrule.lisp (file)

Special Variable: *rule-table*
Package

parseq

Source

defrule.lisp (file)

Special Variable: *terminal-failure-list*
Package

parseq

Source

defrule.lisp (file)

Special Variable: *trace-depth*
Package

parseq

Source

defrule.lisp (file)

Special Variable: *trace-recursive*
Package

parseq

Source

defrule.lisp (file)

Special Variable: *trace-rule*
Package

parseq

Source

defrule.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Macros

Macro: appendf LIST &rest ITEMS

Appends the given item to the list using setf.

Package

parseq

Source

utils.lisp (file)

Macro: case-test (KEYFORM &key TEST) &body CLAUSES
Package

parseq

Source

utils.lisp (file)

Macro: conditional-dynamic-bind (&rest BINDINGS) CONDITION &body BODY

Establishes the dynamic bindings if condition evaluates to true.

Package

parseq

Source

utils.lisp (file)

Macro: f-error TYPE (&rest INITARGS) CONTROL &rest ARGS

Like (error ...), but allows the condition type to be specified (which is required to inherit from simple-condition).

Package

parseq

Source

conditions.lisp (file)

Macro: if-hash (KEY HASH-TABLE &key VAR PLACE) THEN &optional ELSE
Package

parseq

Source

utils.lisp (file)

Macro: let-special (&rest VARS) &body BODY
Package

parseq

Source

utils.lisp (file)

Macro: or2 &rest FORMS
Package

parseq

Source

utils.lisp (file)

Macro: or2-exclusive (EXCLUSION-LIST) &rest FORMS
Package

parseq

Source

utils.lisp (file)

Macro: rule-options-bind (SPECIALS EXTERNALS PROCESSING PACKRAT) OPTIONS NAME &body BODY
Package

parseq

Source

defrule.lisp (file)

Macro: runtime-match TERMINAL EXPR POS TEST RESULT &optional INC
Package

parseq

Source

defrule.lisp (file)

Macro: test-and-advance TERMINAL EXPR POS TEST RESULT &optional INC
Package

parseq

Source

defrule.lisp (file)

Macro: try-and-advance FUNC POS
Package

parseq

Source

defrule.lisp (file)

Macro: with-expansion ((RESULT-VAR SUCCESS-VAR) EXPR RULE POS ARGS) &body BODY
Package

parseq

Source

defrule.lisp (file)

Macro: with-expansion-failure ((RESULT-VAR SUCCESS-VAR) EXPR RULE POS ARGS) THEN ELSE
Package

parseq

Source

defrule.lisp (file)

Macro: with-expansion-success ((RESULT-VAR SUCCESS-VAR) EXPR RULE POS ARGS) THEN ELSE
Package

parseq

Source

defrule.lisp (file)

Macro: with-gensyms (&rest NAMES) &body BODY
Package

parseq

Source

utils.lisp (file)

Macro: with-left-recursion-protection (POS STACK) &body BODY
Package

parseq

Source

defrule.lisp (file)

Macro: with-packrat (ENABLED NAME POS LAMBDA-LIST EXTERNAL-BINDINGS MEMO) &body BODY
Package

parseq

Source

defrule.lisp (file)

Macro: with-special-vars-from-options BINDINGS &body BODY
Package

parseq

Source

defrule.lisp (file)

Macro: with-tracing (NAME POS MEMO) &body BODY
Package

parseq

Source

defrule.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Functions

Function: cat &rest ITEMS
Package

parseq

Source

utils.lisp (file)

Function: check-range COUNT RANGE
Package

parseq

Source

utils.lisp (file)

Function: choice-item TREEPOS TREE

Retrieves an item from the tree by using the given treepointer, or NIL if such a position does not exist.

Package

parseq

Source

utils.lisp (file)

Function: copy-hash-table HASH-TABLE
Package

parseq

Source

utils.lisp (file)

Function: decode-range RANGE
Package

parseq

Source

utils.lisp (file)

Function: expand-! EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-& EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-* EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-+ EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-? EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-and EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-and~ EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-and~~ EXPR REP RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-atom EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-choice INDICES RESULT
Package

parseq

Source

defrule.lisp (file)

Function: expand-destructure DESTRUCT-LAMBDA RESULT BODY
Package

parseq

Source

defrule.lisp (file)

Function: expand-list-expr EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-not EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-or EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-parse-call EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-parse-call-recursion RULE ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-processing-options RESULT PROCS
Package

parseq

Source

defrule.lisp (file)

Function: expand-regexp-bracket-expression EXPR
Package

parseq

Source

defrule.lisp (file)

Function: expand-rep RANGE EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-rule EXPR RULE POS ARGS
Package

parseq

Source

defrule.lisp (file)

Function: expand-sequence EXPR RULES POS ARGS TYPE-TEST TERMINAL
Package

parseq

Source

defrule.lisp (file)

Function: flatten X

Flattens the given tree, x, into a list.

Package

parseq

Source

utils.lisp (file)

Function: have ITEM SEQUENCE &key TEST KEY
Package

parseq

Source

utils.lisp (file)

Function: is-traced TRACE-OPTION
Package

parseq

Source

defrule.lisp (file)

Function: is-traced-with-recursion TRACE-OPTION
Package

parseq

Source

defrule.lisp (file)

Function: l< LIST LENGTH

Tests efficiently whether the length of the list is smaller than the given length.

Package

parseq

Source

utils.lisp (file)

Function: l<= LIST LENGTH

Tests efficiently whether the length of the list is smaller or equal to the given length.

Package

parseq

Source

utils.lisp (file)

Function: l= LIST LENGTH

Tests efficiently whether the length of the list is equal to the given length.

Package

parseq

Source

utils.lisp (file)

Function: l> LIST LENGTH

Tests efficiently whether the length of the list is greater than the given length.

Package

parseq

Source

utils.lisp (file)

Function: l>= LIST LENGTH

Tests efficiently whether the length of the list is greater or equal to the given length.

Package

parseq

Source

utils.lisp (file)

Function: lambda-list-vars LAMBDA-LIST
Package

parseq

Source

utils.lisp (file)

Function: last-1 LIST

Retrieves the last item from the given list.

Package

parseq

Source

utils.lisp (file)

Function: make-checklist COUNTS RANGES
Package

parseq

Source

defrule.lisp (file)

Function: make-packrat-key TREEPOS LAMBDA-LIST EXTERNAL-BINDINGS

Generates a key for the packrat memoization hash table.

Package

parseq

Source

defrule.lisp (file)

Function: make-treepos &rest INDICES

Creates a new tree position object.

Package

parseq

Source

utils.lisp (file)

Function: mklist ITEM
Package

parseq

Source

utils.lisp (file)

Function: parseq-internal RULE SEQUENCE POS
Package

parseq

Source

defrule.lisp (file)

Function: push-terminal-failure POS TERMINAL
Package

parseq

Source

defrule.lisp (file)

Function: quoted-symbol-p X
Package

parseq

Source

utils.lisp (file)

Function: runtime-dispatch EXPR ARG POS
Package

parseq

Source

defrule.lisp (file)

Function: sequence= SEQ-A SEQ-B &key START1 START2 END1 END2 TEST KEY
Package

parseq

Source

utils.lisp (file)

Function: sequencep OBJECT
Package

parseq

Source

utils.lisp (file)

Function: shuffle LIST

Creates a new list in which the items of the given list are shuffled

Package

parseq

Source

utils.lisp (file)

Function: subseq-at SUBSEQ SEQ POS
Package

parseq

Source

utils.lisp (file)

Function: symbol= A B
Package

parseq

Source

utils.lisp (file)

Function: treeitem TREEPOS TREE

Retrieves an item from the tree by using the given treepointer.

Package

parseq

Source

utils.lisp (file)

Function: treepos-copy TREEPOS &optional DEPTH
Package

parseq

Source

utils.lisp (file)

Function: treepos-depth TREEPOS
Package

parseq

Source

utils.lisp (file)

Function: treepos-elt TREEPOS INDEX
Package

parseq

Source

utils.lisp (file)

Function: treepos-highest TREEPOS
Package

parseq

Source

utils.lisp (file)

Function: treepos-length TREEPOS TREE

Determines the length of the item in the tree pointed to by treepos.

Package

parseq

Source

utils.lisp (file)

Function: treepos-lowest TREEPOS
Package

parseq

Source

utils.lisp (file)

Function: treepos-step TREEPOS &optional DELTA

Copies the tree pointer and increments the tree position.

Package

parseq

Source

utils.lisp (file)

Function: treepos-step-down TREEPOS
Package

parseq

Source

utils.lisp (file)

Function: treepos-str TREEPOS
Package

parseq

Source

utils.lisp (file)

Function: treepos-valid TREEPOS TREE

Verifies whether the given position exists in the given tree.

Package

parseq

Source

utils.lisp (file)

Function: treepos= A B
Package

parseq

Source

utils.lisp (file)

Function: treepos> A B
Package

parseq

Source

utils.lisp (file)

Function: two-way-index INDEX LIST
Package

parseq

Source

utils.lisp (file)

Function: unsigned-byte-p OBJECT
Package

parseq

Source

utils.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.4 Conditions

Condition: invalid-terminal-runtime-error ()

Error condition for situations where an invalid terminal in an expression is detected at runtime.

Package

parseq

Source

conditions.lisp (file)

Direct superclasses

runtime-error (condition)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   P  
Index Entry  Section

F
File, Lisp, parseq.asd: The parseq<dot>asd file
File, Lisp, parseq/conditions.lisp: The parseq/conditions<dot>lisp file
File, Lisp, parseq/defrule.lisp: The parseq/defrule<dot>lisp file
File, Lisp, parseq/package.lisp: The parseq/package<dot>lisp file
File, Lisp, parseq/utils.lisp: The parseq/utils<dot>lisp file

L
Lisp File, parseq.asd: The parseq<dot>asd file
Lisp File, parseq/conditions.lisp: The parseq/conditions<dot>lisp file
Lisp File, parseq/defrule.lisp: The parseq/defrule<dot>lisp file
Lisp File, parseq/package.lisp: The parseq/package<dot>lisp file
Lisp File, parseq/utils.lisp: The parseq/utils<dot>lisp file

P
parseq.asd: The parseq<dot>asd file
parseq/conditions.lisp: The parseq/conditions<dot>lisp file
parseq/defrule.lisp: The parseq/defrule<dot>lisp file
parseq/package.lisp: The parseq/package<dot>lisp file
parseq/utils.lisp: The parseq/utils<dot>lisp file

Jump to:   F   L   P  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
A   C   D   E   F   G   H   I   L   M   O   P   Q   R   S   T   U   W  
Index Entry  Section

(
(setf parse-error-position): Exported generic functions
(setf parse-error-position): Exported generic functions
(setf parse-error-terminals): Exported generic functions
(setf parse-error-terminals): Exported generic functions

A
appendf: Internal macros

C
case-test: Internal macros
cat: Internal functions
check-range: Internal functions
choice-item: Internal functions
conditional-dynamic-bind: Internal macros
copy-hash-table: Internal functions

D
decode-range: Internal functions
defrule: Exported macros

E
expand-!: Internal functions
expand-&: Internal functions
expand-*: Internal functions
expand-+: Internal functions
expand-?: Internal functions
expand-and: Internal functions
expand-and~: Internal functions
expand-and~~: Internal functions
expand-atom: Internal functions
expand-choice: Internal functions
expand-destructure: Internal functions
expand-list-expr: Internal functions
expand-not: Internal functions
expand-or: Internal functions
expand-parse-call: Internal functions
expand-parse-call-recursion: Internal functions
expand-processing-options: Internal functions
expand-regexp-bracket-expression: Internal functions
expand-rep: Internal functions
expand-rule: Internal functions
expand-sequence: Internal functions

F
f-error: Internal macros
flatten: Internal functions
Function, cat: Internal functions
Function, check-range: Internal functions
Function, choice-item: Internal functions
Function, copy-hash-table: Internal functions
Function, decode-range: Internal functions
Function, expand-!: Internal functions
Function, expand-&: Internal functions
Function, expand-*: Internal functions
Function, expand-+: Internal functions
Function, expand-?: Internal functions
Function, expand-and: Internal functions
Function, expand-and~: Internal functions
Function, expand-and~~: Internal functions
Function, expand-atom: Internal functions
Function, expand-choice: Internal functions
Function, expand-destructure: Internal functions
Function, expand-list-expr: Internal functions
Function, expand-not: Internal functions
Function, expand-or: Internal functions
Function, expand-parse-call: Internal functions
Function, expand-parse-call-recursion: Internal functions
Function, expand-processing-options: Internal functions
Function, expand-regexp-bracket-expression: Internal functions
Function, expand-rep: Internal functions
Function, expand-rule: Internal functions
Function, expand-sequence: Internal functions
Function, flatten: Internal functions
Function, have: Internal functions
Function, is-traced: Internal functions
Function, is-traced-with-recursion: Internal functions
Function, l<: Internal functions
Function, l<=: Internal functions
Function, l=: Internal functions
Function, l>: Internal functions
Function, l>=: Internal functions
Function, lambda-list-vars: Internal functions
Function, last-1: Internal functions
Function, make-checklist: Internal functions
Function, make-packrat-key: Internal functions
Function, make-treepos: Internal functions
Function, mklist: Internal functions
Function, parseq: Exported functions
Function, parseq-internal: Internal functions
Function, push-terminal-failure: Internal functions
Function, quoted-symbol-p: Internal functions
Function, runtime-dispatch: Internal functions
Function, sequence=: Internal functions
Function, sequencep: Internal functions
Function, shuffle: Internal functions
Function, subseq-at: Internal functions
Function, symbol=: Internal functions
Function, trace-rule: Exported functions
Function, treeitem: Internal functions
Function, treepos-copy: Internal functions
Function, treepos-depth: Internal functions
Function, treepos-elt: Internal functions
Function, treepos-highest: Internal functions
Function, treepos-length: Internal functions
Function, treepos-lowest: Internal functions
Function, treepos-step: Internal functions
Function, treepos-step-down: Internal functions
Function, treepos-str: Internal functions
Function, treepos-valid: Internal functions
Function, treepos=: Internal functions
Function, treepos>: Internal functions
Function, two-way-index: Internal functions
Function, unsigned-byte-p: Internal functions
Function, untrace-rule: Exported functions

G
Generic Function, (setf parse-error-position): Exported generic functions
Generic Function, (setf parse-error-terminals): Exported generic functions
Generic Function, parse-error-position: Exported generic functions
Generic Function, parse-error-terminals: Exported generic functions

H
have: Internal functions

I
if-hash: Internal macros
is-traced: Internal functions
is-traced-with-recursion: Internal functions

L
l<: Internal functions
l<=: Internal functions
l=: Internal functions
l>: Internal functions
l>=: Internal functions
lambda-list-vars: Internal functions
last-1: Internal functions
let-special: Internal macros

M
Macro, appendf: Internal macros
Macro, case-test: Internal macros
Macro, conditional-dynamic-bind: Internal macros
Macro, defrule: Exported macros
Macro, f-error: Internal macros
Macro, if-hash: Internal macros
Macro, let-special: Internal macros
Macro, or2: Internal macros
Macro, or2-exclusive: Internal macros
Macro, rule-options-bind: Internal macros
Macro, runtime-match: Internal macros
Macro, test-and-advance: Internal macros
Macro, try-and-advance: Internal macros
Macro, with-expansion: Internal macros
Macro, with-expansion-failure: Internal macros
Macro, with-expansion-success: Internal macros
Macro, with-gensyms: Internal macros
Macro, with-left-recursion-protection: Internal macros
Macro, with-local-rules: Exported macros
Macro, with-packrat: Internal macros
Macro, with-saved-rules: Exported macros
Macro, with-special-vars-from-options: Internal macros
Macro, with-tracing: Internal macros
make-checklist: Internal functions
make-packrat-key: Internal functions
make-treepos: Internal functions
Method, (setf parse-error-position): Exported generic functions
Method, (setf parse-error-terminals): Exported generic functions
Method, parse-error-position: Exported generic functions
Method, parse-error-terminals: Exported generic functions
mklist: Internal functions

O
or2: Internal macros
or2-exclusive: Internal macros

P
parse-error-position: Exported generic functions
parse-error-position: Exported generic functions
parse-error-terminals: Exported generic functions
parse-error-terminals: Exported generic functions
parseq: Exported functions
parseq-internal: Internal functions
push-terminal-failure: Internal functions

Q
quoted-symbol-p: Internal functions

R
rule-options-bind: Internal macros
runtime-dispatch: Internal functions
runtime-match: Internal macros

S
sequence=: Internal functions
sequencep: Internal functions
shuffle: Internal functions
subseq-at: Internal functions
symbol=: Internal functions

T
test-and-advance: Internal macros
trace-rule: Exported functions
treeitem: Internal functions
treepos-copy: Internal functions
treepos-depth: Internal functions
treepos-elt: Internal functions
treepos-highest: Internal functions
treepos-length: Internal functions
treepos-lowest: Internal functions
treepos-step: Internal functions
treepos-step-down: Internal functions
treepos-str: Internal functions
treepos-valid: Internal functions
treepos=: Internal functions
treepos>: Internal functions
try-and-advance: Internal macros
two-way-index: Internal functions

U
unsigned-byte-p: Internal functions
untrace-rule: Exported functions

W
with-expansion: Internal macros
with-expansion-failure: Internal macros
with-expansion-success: Internal macros
with-gensyms: Internal macros
with-left-recursion-protection: Internal macros
with-local-rules: Exported macros
with-packrat: Internal macros
with-saved-rules: Exported macros
with-special-vars-from-options: Internal macros
with-tracing: Internal macros

Jump to:   (  
A   C   D   E   F   G   H   I   L   M   O   P   Q   R   S   T   U   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
P   S   T  
Index Entry  Section

*
*ascii-standard-chars*: Internal special variables
*packrat-table*: Internal special variables
*rule-table*: Internal special variables
*terminal-failure-list*: Internal special variables
*trace-depth*: Internal special variables
*trace-recursive*: Internal special variables
*trace-rule*: Internal special variables

P
position: Exported conditions

S
Slot, position: Exported conditions
Slot, terminals: Exported conditions
Special Variable, *ascii-standard-chars*: Internal special variables
Special Variable, *packrat-table*: Internal special variables
Special Variable, *rule-table*: Internal special variables
Special Variable, *terminal-failure-list*: Internal special variables
Special Variable, *trace-depth*: Internal special variables
Special Variable, *trace-recursive*: Internal special variables
Special Variable, *trace-rule*: Internal special variables

T
terminals: Exported conditions

Jump to:   *  
P   S   T  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   G   I   L   P   R   S   U  
Index Entry  Section

C
Condition, generic-parse-error: Exported conditions
Condition, invalid-operation-error: Exported conditions
Condition, invalid-rule-error: Exported conditions
Condition, invalid-terminal-error: Exported conditions
Condition, invalid-terminal-runtime-error: Internal conditions
Condition, left-recursion-error: Exported conditions
Condition, parse-junk-error: Exported conditions
Condition, parse-match-error: Exported conditions
Condition, parseq-error: Exported conditions
Condition, processing-options-error: Exported conditions
Condition, rule-definition-error: Exported conditions
Condition, runtime-error: Exported conditions
Condition, unknown-rule-error: Exported conditions

G
generic-parse-error: Exported conditions

I
invalid-operation-error: Exported conditions
invalid-rule-error: Exported conditions
invalid-terminal-error: Exported conditions
invalid-terminal-runtime-error: Internal conditions

L
left-recursion-error: Exported conditions

P
Package, parseq: The parseq package
parse-junk-error: Exported conditions
parse-match-error: Exported conditions
parseq: The parseq system
parseq: The parseq package
parseq-error: Exported conditions
processing-options-error: Exported conditions

R
rule-definition-error: Exported conditions
runtime-error: Exported conditions

S
System, parseq: The parseq system

U
unknown-rule-error: Exported conditions

Jump to:   C   G   I   L   P   R   S   U