The alexa Reference Manual

This is the alexa Reference Manual, version 2.1.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 03:14:08 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 alexa

A lexical analyzer generator.

Author

Robert Smith <>

License

BSD 3-clause (See LICENSE.txt)

Version

2.1.1

Dependencies
  • alexandria (system).
  • cl-ppcre (system).
Source

alexa.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


3.1 alexa/src

Dependency

license.txt (file).

Source

alexa.asd.

Parent Component

alexa (system).

Child Components

4 Files

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


4.1 Lisp


4.1.1 alexa/alexa.asd

Source

alexa.asd.

Parent Component

alexa (system).

ASDF Systems

alexa.


4.1.2 alexa/src/package.lisp

Source

alexa.asd.

Parent Component

src (module).

Packages

4.1.3 alexa/src/alexa.lisp

Dependency

package.lisp (file).

Source

alexa.asd.

Parent Component

src (module).

Public Interface
Internals

4.2 Static


4.2.1 alexa/LICENSE.txt

Source

alexa.asd.

Parent Component

alexa (system).


5 Packages

Packages are listed by definition order.


5.1 alexa

A lexical analyzer generator.

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5.2 alexa-internal

A package to stash away generated symbols.

Source

package.lisp.


6 Definitions

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


6.1 Public Interface


6.1.1 Macros

Macro: define-string-lexer (name &body body)

Define a lexical analyzer named NAME.

Defining a lexical analyzer is actually defining a function named NAME whose lambda list is

(STRING &KEY (START 0) (END (LENGTH STRING)))

The STRING is the string to be analyzed, and START/END are the starting and ending positions to be looked at. Calling the function named NAME will produce a closure which, if called repeatedly, will produce results according to the lexical rules defined. When the input string is exhausted, NIL is returned, and the string will be unbound within the closure to allow garbage collection.

If STRING is not a SIMPLE-STRING, then it will be coerced into one (which will cons).

The lexer will fire the action which had the longest match, and ties are broken based on the order of the actions (earlier ones are preferred). This rule can be selectively disabled for a particular action if one declares it to be a short circuiting (see below).

Signals LEXER-MATCH-ERROR as a continuable error if no match was found.

The syntax of BODY is:

<doc string>?
(<alias definition>*)
<lexical action>*

An <alias definition> is a list

(<keyword> <regex string>)

The name of the keyword may be used in the <lexical action> regexes. A <lexical action> is a list

(<pattern spec> &body <code>)

A <pattern spec> has the following grammar:

<pattern spec> := <regex string>
| (EAGER <regex string>)

The EAGER option is defined below.

The <regex string> is matched against the input string greedily and in the order they are listed in the BODY. When the longest match is found, assuming no EAGER declarations, it will execute <code>. Within <code>, the following symbols are bound:

$1, $2, ..., $n: String match on (unnamed) register n
$NAME : String match on named register (?<NAME>...)
$@ : Entire string match.
$<, $> : Start and end position of match.

Generally, <code> should explicitly RETURN some token object for a semantic analyzer to examine. Currently, only a single value can be returned. (All other values will be ignored.) An explicit RETURN is needed. If no RETURN is provided, then the lexer will throw away the match and move on as if the lexer were called again. (This is most often used to ignore matches, like whitespace.)

The <regex string> of the lexical action may use the names of the symbols defined in the <alias definition> forms. For example, given the alias definitions

((:int "\\d+")
(:ident "[a-z]+"))

one can use {{INT}} and {{IDENT}} within the <regex string>s of the <lexical action>.

If the <pattern spec> uses EAGER, then the lexical action will "short circuit". The EAGER option states that if a match occurs on this pattern, <code> should be executed immediately, disregarding the "longest match" rule. This can be used for certain kinds of optimizations.

Package

alexa.

Source

alexa.lisp.


6.1.2 Conditions

Condition: lexer-match-error

Error to be signaled if the lexer didn’t find a match.

Package

alexa.

Source

alexa.lisp.

Direct superclasses

simple-error.


6.2 Internals


6.2.1 Macros

Macro: let-lazy (bindings &body body)
Package

alexa.

Source

alexa.lisp.


6.2.2 Ordinary functions

Function: copy-pattern (instance)
Package

alexa.

Source

alexa.lisp.

Function: empty-match-error (regex)
Package

alexa.

Source

alexa.lisp.

Function: extract-registers (parse-tree)
Package

alexa.

Source

alexa.lisp.

Function: fill-in-aliases (aliases regex)
Package

alexa.

Source

alexa.lisp.

Function: generate-pattern-execution-code (pat string-var match-start-var match-end-var reg-starts-var reg-ends-var)
Package

alexa.

Source

alexa.lisp.

Function: generate-pattern-match-code (pat execute-tag string-var start-var end-var match-start-var match-end-var reg-starts-var reg-ends-var max-match-length-var match-rule-index-var i)
Package

alexa.

Source

alexa.lisp.

Function: make-pattern (&key regex short-circuit-p parse-tree num-registers register-names scanner-name fire-name code)
Package

alexa.

Source

alexa.lisp.

Reader: pattern-code (instance)
Writer: (setf pattern-code) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

code.

Reader: pattern-fire-name (instance)
Writer: (setf pattern-fire-name) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

fire-name.

Reader: pattern-num-registers (instance)
Writer: (setf pattern-num-registers) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

num-registers.

Function: pattern-p (object)
Package

alexa.

Source

alexa.lisp.

Reader: pattern-parse-tree (instance)
Writer: (setf pattern-parse-tree) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

parse-tree.

Reader: pattern-regex (instance)
Writer: (setf pattern-regex) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

regex.

Reader: pattern-register-names (instance)
Writer: (setf pattern-register-names) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

register-names.

Function: pattern-register-variables (pat package)
Package

alexa.

Source

alexa.lisp.

Reader: pattern-scanner-name (instance)
Writer: (setf pattern-scanner-name) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

scanner-name.

Reader: pattern-short-circuit-p (instance)
Writer: (setf pattern-short-circuit-p) (instance)
Package

alexa.

Source

alexa.lisp.

Target Slot

short-circuit-p.

Function: walk-tree (f tree)
Package

alexa.

Source

alexa.lisp.


6.2.3 Structures

Structure: pattern
Package

alexa.

Source

alexa.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: regex
Type

string

Readers

pattern-regex.

Writers

(setf pattern-regex).

Slot: short-circuit-p
Type

boolean

Readers

pattern-short-circuit-p.

Writers

(setf pattern-short-circuit-p).

Slot: parse-tree
Readers

pattern-parse-tree.

Writers

(setf pattern-parse-tree).

Slot: num-registers
Type

integer

Readers

pattern-num-registers.

Writers

(setf pattern-num-registers).

Slot: register-names
Type

list

Readers

pattern-register-names.

Writers

(setf pattern-register-names).

Slot: scanner-name
Type

symbol

Readers

pattern-scanner-name.

Writers

(setf pattern-scanner-name).

Slot: fire-name
Type

symbol

Readers

pattern-fire-name.

Writers

(setf pattern-fire-name).

Slot: code
Readers

pattern-code.

Writers

(setf pattern-code).


6.2.4 Types

Type: non-negative-fixnum ()
Package

alexa.

Source

alexa.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
C   D   E   F   G   L   M   P   W  
Index Entry  Section

(
(setf pattern-code): Private ordinary functions
(setf pattern-fire-name): Private ordinary functions
(setf pattern-num-registers): Private ordinary functions
(setf pattern-parse-tree): Private ordinary functions
(setf pattern-regex): Private ordinary functions
(setf pattern-register-names): Private ordinary functions
(setf pattern-scanner-name): Private ordinary functions
(setf pattern-short-circuit-p): Private ordinary functions

C
copy-pattern: Private ordinary functions

D
define-string-lexer: Public macros

E
empty-match-error: Private ordinary functions
extract-registers: Private ordinary functions

F
fill-in-aliases: Private ordinary functions
Function, (setf pattern-code): Private ordinary functions
Function, (setf pattern-fire-name): Private ordinary functions
Function, (setf pattern-num-registers): Private ordinary functions
Function, (setf pattern-parse-tree): Private ordinary functions
Function, (setf pattern-regex): Private ordinary functions
Function, (setf pattern-register-names): Private ordinary functions
Function, (setf pattern-scanner-name): Private ordinary functions
Function, (setf pattern-short-circuit-p): Private ordinary functions
Function, copy-pattern: Private ordinary functions
Function, empty-match-error: Private ordinary functions
Function, extract-registers: Private ordinary functions
Function, fill-in-aliases: Private ordinary functions
Function, generate-pattern-execution-code: Private ordinary functions
Function, generate-pattern-match-code: Private ordinary functions
Function, make-pattern: Private ordinary functions
Function, pattern-code: Private ordinary functions
Function, pattern-fire-name: Private ordinary functions
Function, pattern-num-registers: Private ordinary functions
Function, pattern-p: Private ordinary functions
Function, pattern-parse-tree: Private ordinary functions
Function, pattern-regex: Private ordinary functions
Function, pattern-register-names: Private ordinary functions
Function, pattern-register-variables: Private ordinary functions
Function, pattern-scanner-name: Private ordinary functions
Function, pattern-short-circuit-p: Private ordinary functions
Function, walk-tree: Private ordinary functions

G
generate-pattern-execution-code: Private ordinary functions
generate-pattern-match-code: Private ordinary functions

L
let-lazy: Private macros

M
Macro, define-string-lexer: Public macros
Macro, let-lazy: Private macros
make-pattern: Private ordinary functions

P
pattern-code: Private ordinary functions
pattern-fire-name: Private ordinary functions
pattern-num-registers: Private ordinary functions
pattern-p: Private ordinary functions
pattern-parse-tree: Private ordinary functions
pattern-regex: Private ordinary functions
pattern-register-names: Private ordinary functions
pattern-register-variables: Private ordinary functions
pattern-scanner-name: Private ordinary functions
pattern-short-circuit-p: Private ordinary functions

W
walk-tree: Private ordinary functions