The mexpr Reference Manual

This is the mexpr Reference Manual, version 0.2.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 07:02:46 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 mexpr

Macro for infix math expressions.

Author

Thayne McCombs <>

License

LLPGL

Long Description

mexpr is a library which contains a macro for
embedding mathematical expressions in lisp code with a more traditional infix syntax. It also contains a reader macro for said syntax, and a macro to extend the syntax with additional operators.

Version

0.2.0

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

mexpr.asd.

Child Components

3 Files

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


3.1 Lisp


3.1.1 mexpr/mexpr.asd

Source

mexpr.asd.

Parent Component

mexpr (system).

ASDF Systems

mexpr.


3.1.2 mexpr/package.lisp

Source

mexpr.asd.

Parent Component

mexpr (system).

Packages

bytecurry.mexpr.


3.1.3 mexpr/mexpr.lisp

Dependency

package.lisp (file).

Source

mexpr.asd.

Parent Component

mexpr (system).

Public Interface
Internals

3.1.4 mexpr/operators.lisp

Dependency

mexpr.lisp (file).

Source

mexpr.asd.

Parent Component

mexpr (system).


4 Packages

Packages are listed by definition order.


4.1 bytecurry.mexpr

A library for embedding mathematical expressions in lisp code using traditional infix syntax.

Source

package.lisp.

Nickname

mexpr

Use List
  • alexandria.
  • cl-syntax.
  • common-lisp.
Public Interface
Internals

5 Definitions

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


5.1 Public Interface


5.1.1 Macros

Macro: defop (name precedence &optional func)

Define a new infix operator with the given name and precedence.

NAME is the symbol which will be used as a binary operator in an infix expression PRECEDENCE is a positive integer for the precedence of the operator
FUNC is a symbol or lambda form that the operator will translate into during macro-expansion

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Macro: enable-infix-syntax ()

Enable infix syntax with ’#n’, for example: #n(3 + 4) => 7

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Macro: infix (&rest exprs)

Macro to convert an infix expression, into an s-expression.

Package

bytecurry.mexpr.

Source

mexpr.lisp.


5.1.2 Ordinary functions

Function: infix-reader (stream char narg)

Reader macro function to read infix expressions.

Package

bytecurry.mexpr.

Source

mexpr.lisp.


5.1.3 Generic functions

Generic Reader: syntax-error-type (condition)
Package

bytecurry.mexpr.

Methods
Reader Method: syntax-error-type ((condition syntax-error))
Source

mexpr.lisp.

Target Slot

type.


5.1.4 Conditions

Condition: syntax-error

Error due to invalid syntax in infix expression

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Direct superclasses

error.

Direct methods

syntax-error-type.

Direct slots
Slot: type
Package

common-lisp.

Initargs

:type

Readers

syntax-error-type.

Writers

This slot is read-only.


5.2 Internals


5.2.1 Special variables

Special Variable: *operators*

Hash map of operator symbols to precedence.

Package

bytecurry.mexpr.

Source

mexpr.lisp.


5.2.2 Ordinary functions

Function: copy-op-state (instance)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: copy-operator (instance)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: do-operation (operator state)

Do the operation for the operands on the stack.

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: finalize-operations (state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: get-operator-func (op)

Get the symbol or lambda form for the operator.

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: get-precedence (op &optional default)

Get the precedence of an operator.

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: handle-end-group (state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: handle-expr (state expr)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: make-op-state (&key operands operators)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: make-operator (&key precedence func)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: mexpr-impl (exprs)

Convert an infix expression, into an s-expression –implementation.

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Reader: op-state-operands (instance)
Writer: (setf op-state-operands) (instance)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Target Slot

operands.

Reader: op-state-operators (instance)
Writer: (setf op-state-operators) (instance)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Target Slot

operators.

Function: op-state-p (object)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Reader: operator-func (instance)
Writer: (setf operator-func) (instance)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Target Slot

func.

Function: operator-p (object)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Reader: operator-precedence (instance)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Target Slot

precedence.

Function: pop-operand (state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: pop-operator (state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: push-operand (op state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: push-operator (op state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.

Function: reduce-state (state)
Package

bytecurry.mexpr.

Source

mexpr.lisp.


5.2.3 Structures

Structure: op-state

Structure for state of the operation stacks.

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: operands
Type

list

Readers

op-state-operands.

Writers

(setf op-state-operands).

Slot: operators
Type

list

Readers

op-state-operators.

Writers

(setf op-state-operators).

Structure: operator

Struct for information about an operator.

Package

bytecurry.mexpr.

Source

mexpr.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: precedence
Type

integer

Initform

0

Readers

operator-precedence.

Writers

This slot is read-only.

Slot: func
Type

bytecurry.mexpr::form-head

Initform

(quote values)

Readers

operator-func.

Writers

(setf operator-func).


5.2.4 Types

Type: form-head ()

The first subform of a compound form.

Package

bytecurry.mexpr.

Source

mexpr.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
C   D   E   F   G   H   I   M   O   P   R   S  
Index Entry  Section

(
(setf op-state-operands): Private ordinary functions
(setf op-state-operators): Private ordinary functions
(setf operator-func): Private ordinary functions

C
copy-op-state: Private ordinary functions
copy-operator: Private ordinary functions

D
defop: Public macros
do-operation: Private ordinary functions

E
enable-infix-syntax: Public macros

F
finalize-operations: Private ordinary functions
Function, (setf op-state-operands): Private ordinary functions
Function, (setf op-state-operators): Private ordinary functions
Function, (setf operator-func): Private ordinary functions
Function, copy-op-state: Private ordinary functions
Function, copy-operator: Private ordinary functions
Function, do-operation: Private ordinary functions
Function, finalize-operations: Private ordinary functions
Function, get-operator-func: Private ordinary functions
Function, get-precedence: Private ordinary functions
Function, handle-end-group: Private ordinary functions
Function, handle-expr: Private ordinary functions
Function, infix-reader: Public ordinary functions
Function, make-op-state: Private ordinary functions
Function, make-operator: Private ordinary functions
Function, mexpr-impl: Private ordinary functions
Function, op-state-operands: Private ordinary functions
Function, op-state-operators: Private ordinary functions
Function, op-state-p: Private ordinary functions
Function, operator-func: Private ordinary functions
Function, operator-p: Private ordinary functions
Function, operator-precedence: Private ordinary functions
Function, pop-operand: Private ordinary functions
Function, pop-operator: Private ordinary functions
Function, push-operand: Private ordinary functions
Function, push-operator: Private ordinary functions
Function, reduce-state: Private ordinary functions

G
Generic Function, syntax-error-type: Public generic functions
get-operator-func: Private ordinary functions
get-precedence: Private ordinary functions

H
handle-end-group: Private ordinary functions
handle-expr: Private ordinary functions

I
infix: Public macros
infix-reader: Public ordinary functions

M
Macro, defop: Public macros
Macro, enable-infix-syntax: Public macros
Macro, infix: Public macros
make-op-state: Private ordinary functions
make-operator: Private ordinary functions
Method, syntax-error-type: Public generic functions
mexpr-impl: Private ordinary functions

O
op-state-operands: Private ordinary functions
op-state-operators: Private ordinary functions
op-state-p: Private ordinary functions
operator-func: Private ordinary functions
operator-p: Private ordinary functions
operator-precedence: Private ordinary functions

P
pop-operand: Private ordinary functions
pop-operator: Private ordinary functions
push-operand: Private ordinary functions
push-operator: Private ordinary functions

R
reduce-state: Private ordinary functions

S
syntax-error-type: Public generic functions
syntax-error-type: Public generic functions