The ugly-tiny-infix-macro Reference Manual

Table of Contents

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

The ugly-tiny-infix-macro Reference Manual

This is the ugly-tiny-infix-macro Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:42:36 2018 GMT+0.


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

1 Introduction

Ugly Tiny Infix Macro

This is a powerful lisp macro for the purpose of writing your expressions in infix notation while not losing out on lisp's power.

Let's look at a few examples

Examples

At its simplest,

($ 1 + 2)		; gets converted to (+ 1 2), where name of the macro is $
($ t and nil) 	; gets converted to (and t nil)
($ 3 > 5) 		; gets converted to (> 3 5)
($ 1 + 2 + 3) 	; gets converted to (+ (+ 1 2) 3)

You can use various operators (which is just a fancy name for a function) at once and they're grouped according to the precedence.

Default precedence of operators that ships with the project is taken from the C++ standard. Check the default-operator-precedence-alist.lisp file for a full list of operators available by default. Check out the section on customizing the list of operators and their priorities if you wish to do so.

($ 1 + 2 *  3)      ; gets converted to (+ 1 (* 2 3))
($ 1 < 2 and 2 < 3) ; gets converted to (AND (< 1 2) (< 2 3))

Anything within parentheses at position of an operand is treated like a lisp form.

($ 2 + (max 9 10 11)) ; gets converted to (+ 2 (max 9 10 11)). It could have been any function / lisp form.
($ 6 / ($ 1 + 2))     ; gets converted to (/ 6 ($ 1 + 2)), and then subsequently to (/6 (+ 1 2))

As illustrated by the last example, nesting the macro can be used for "grouping" or "higher precedence" so that it's evaluated first like is done with brackets in mathematical notation.

You may write the last example as 6 / (1 + 2) in math. Most deeply nested brackets are executed the first, and same is the case when you nest this macro.

WARNING: As explained in the example on nesting the macro, brackets are assumed to be valid lisp forms. Do not use them for grouping. Writing ($ 6 / (1 + 2)) will give you an error as it's expanded to (/ 6 (1 + 2)) and (1 + 2) is not a valid lisp form. Your lisp environment will try to evaluate it and find that 1 isn't name of a function that can be called with the arguments + and 2. This is what puts "ugly" in the the name of the project, because it's not prettiest to the eye, but some may find that it's easy to reason about.

Installation

This package is available on quicklisp. You may install it using

(ql:quickload :ugly-tiny-infix-macro)

Alternately, you can dowload the source files manually and load it via asdf

Usage

The package, named :ugly-tiny-lisp-macro with the nickname :ugly-infix exports three symbols -

Customizing The List of Operators and Their Priorities

Operator precedence is stored as an alist associated with the symbol *operator-precedence-alist*. An example of a valid alist that one may assign for DMAS precedence may look like:

(setf ugly-infix:*operator-precedence-alist*
	  '(( / . 1) ; a lower number means a higher priority/precedence
	    ( * . 1) ; / and * are at the same priority/precedence
	    ( + . 2) ; a higher number means a lower priority/precedence
	    ( - . 2)))

You may modify *operator-precedence-alist* in any manner by resetting, pushing, etc as long as it is a valid alist of operators and their priority. The position in the list / order of cons elements does not matter.

Miscellaneous

Note that this project only deals with binary operators, e.g. functions that accept (operate on) two arguments.

License

This project is licensed under the terms of APACHE 2.0 license. Please see the LICENSE file for the text of the license.


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 ugly-tiny-infix-macro

Author

Peeyush Kushwaha <peeyush.p97+dev@gmail.com>

License

Apache License, Version 2.0

Description

A tiny and simple macro to allow writing binary operations in infix notation

Source

ugly-tiny-infix-macro.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 ugly-tiny-infix-macro.asd

Location

ugly-tiny-infix-macro.asd

Systems

ugly-tiny-infix-macro (system)


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

3.1.2 ugly-tiny-infix-macro/defpackage.lisp

Parent

ugly-tiny-infix-macro (system)

Location

defpackage.lisp

Packages

ugly-tiny-infix-macro


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

3.1.3 ugly-tiny-infix-macro/default-operator-precedence-alist.lisp

Dependency

defpackage.lisp (file)

Parent

ugly-tiny-infix-macro (system)

Location

default-operator-precedence-alist.lisp

Exported Definitions

*operator-precedence-alist* (special variable)


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

3.1.4 ugly-tiny-infix-macro/error-handling.lisp

Dependency

default-operator-precedence-alist.lisp (file)

Parent

ugly-tiny-infix-macro (system)

Location

error-handling.lisp

Exported Definitions

malformed-infix-expression-error (condition)

Internal Definitions

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

3.1.5 ugly-tiny-infix-macro/ugly-tiny-infix-macro.lisp

Dependency

error-handling.lisp (file)

Parent

ugly-tiny-infix-macro (system)

Location

ugly-tiny-infix-macro.lisp

Exported Definitions

$ (macro)

Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 ugly-tiny-infix-macro

Source

defpackage.lisp (file)

Nickname

ugly-infix

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 Special variables

Special Variable: *operator-precedence-alist*
Package

ugly-tiny-infix-macro

Source

default-operator-precedence-alist.lisp (file)


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

5.1.2 Macros

Macro: $ &rest LIST-OF-EXPRESSIONS

Infix binary operations for lisp!

Package

ugly-tiny-infix-macro

Source

ugly-tiny-infix-macro.lisp (file)


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

5.1.3 Conditions

Condition: malformed-infix-expression-error ()
Package

ugly-tiny-infix-macro

Source

error-handling.lisp (file)

Direct superclasses

error (condition)

Direct methods
Direct slots
Slot: text
Initargs

:text

Readers

malformed-infix-expression-error-text (generic function)

Slot: expression
Initargs

:expression

Readers

malformed-infix-expression-error-expression (generic function)


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

5.2 Internal definitions


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

5.2.1 Functions

Function: apply-popped POPPED-STACK QUEUE
Package

ugly-tiny-infix-macro

Source

ugly-tiny-infix-macro.lisp (file)

Function: check-list-of-expressions LIST-OF-EXPRESSIONS OPERATOR-PRECEDENCE-ALIST
Package

ugly-tiny-infix-macro

Source

error-handling.lisp (file)

Function: check-operator-precedence-alist OPERATOR-PRECEDENCE-ALIST
Package

ugly-tiny-infix-macro

Source

error-handling.lisp (file)

Function: recursively-pop-stack STACK ELEMENT OPERATOR-PRECEDENCE-ALIST &optional POPPED
Package

ugly-tiny-infix-macro

Source

ugly-tiny-infix-macro.lisp (file)

Function: shunting-yard LIST-OF-EXPRESSIONS OPERATOR-PRECEDENCE-ALIST
Package

ugly-tiny-infix-macro

Source

ugly-tiny-infix-macro.lisp (file)


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

5.2.2 Generic functions

Generic Function: malformed-infix-expression-error-expression CONDITION
Package

ugly-tiny-infix-macro

Methods
Method: malformed-infix-expression-error-expression (CONDITION malformed-infix-expression-error)
Source

error-handling.lisp (file)

Generic Function: malformed-infix-expression-error-text CONDITION
Package

ugly-tiny-infix-macro

Methods
Method: malformed-infix-expression-error-text (CONDITION malformed-infix-expression-error)
Source

error-handling.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   U  
Index Entry  Section

F
File, Lisp, ugly-tiny-infix-macro.asd: The ugly-tiny-infix-macro<dot>asd file
File, Lisp, ugly-tiny-infix-macro/default-operator-precedence-alist.lisp: The ugly-tiny-infix-macro/default-operator-precedence-alist<dot>lisp file
File, Lisp, ugly-tiny-infix-macro/defpackage.lisp: The ugly-tiny-infix-macro/defpackage<dot>lisp file
File, Lisp, ugly-tiny-infix-macro/error-handling.lisp: The ugly-tiny-infix-macro/error-handling<dot>lisp file
File, Lisp, ugly-tiny-infix-macro/ugly-tiny-infix-macro.lisp: The ugly-tiny-infix-macro/ugly-tiny-infix-macro<dot>lisp file

L
Lisp File, ugly-tiny-infix-macro.asd: The ugly-tiny-infix-macro<dot>asd file
Lisp File, ugly-tiny-infix-macro/default-operator-precedence-alist.lisp: The ugly-tiny-infix-macro/default-operator-precedence-alist<dot>lisp file
Lisp File, ugly-tiny-infix-macro/defpackage.lisp: The ugly-tiny-infix-macro/defpackage<dot>lisp file
Lisp File, ugly-tiny-infix-macro/error-handling.lisp: The ugly-tiny-infix-macro/error-handling<dot>lisp file
Lisp File, ugly-tiny-infix-macro/ugly-tiny-infix-macro.lisp: The ugly-tiny-infix-macro/ugly-tiny-infix-macro<dot>lisp file

U
ugly-tiny-infix-macro.asd: The ugly-tiny-infix-macro<dot>asd file
ugly-tiny-infix-macro/default-operator-precedence-alist.lisp: The ugly-tiny-infix-macro/default-operator-precedence-alist<dot>lisp file
ugly-tiny-infix-macro/defpackage.lisp: The ugly-tiny-infix-macro/defpackage<dot>lisp file
ugly-tiny-infix-macro/error-handling.lisp: The ugly-tiny-infix-macro/error-handling<dot>lisp file
ugly-tiny-infix-macro/ugly-tiny-infix-macro.lisp: The ugly-tiny-infix-macro/ugly-tiny-infix-macro<dot>lisp file

Jump to:   F   L   U  

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

A.2 Functions

Jump to:   $  
A   C   F   G   M   R   S  
Index Entry  Section

$
$: Exported macros

A
apply-popped: Internal functions

C
check-list-of-expressions: Internal functions
check-operator-precedence-alist: Internal functions

F
Function, apply-popped: Internal functions
Function, check-list-of-expressions: Internal functions
Function, check-operator-precedence-alist: Internal functions
Function, recursively-pop-stack: Internal functions
Function, shunting-yard: Internal functions

G
Generic Function, malformed-infix-expression-error-expression: Internal generic functions
Generic Function, malformed-infix-expression-error-text: Internal generic functions

M
Macro, $: Exported macros
malformed-infix-expression-error-expression: Internal generic functions
malformed-infix-expression-error-expression: Internal generic functions
malformed-infix-expression-error-text: Internal generic functions
malformed-infix-expression-error-text: Internal generic functions
Method, malformed-infix-expression-error-expression: Internal generic functions
Method, malformed-infix-expression-error-text: Internal generic functions

R
recursively-pop-stack: Internal functions

S
shunting-yard: Internal functions

Jump to:   $  
A   C   F   G   M   R   S  

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

A.3 Variables

Jump to:   *  
E   S   T  
Index Entry  Section

*
*operator-precedence-alist*: Exported special variables

E
expression: Exported conditions

S
Slot, expression: Exported conditions
Slot, text: Exported conditions
Special Variable, *operator-precedence-alist*: Exported special variables

T
text: Exported conditions

Jump to:   *  
E   S   T  

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

A.4 Data types

Jump to:   C   M   P   S   U  
Index Entry  Section

C
Condition, malformed-infix-expression-error: Exported conditions

M
malformed-infix-expression-error: Exported conditions

P
Package, ugly-tiny-infix-macro: The ugly-tiny-infix-macro package

S
System, ugly-tiny-infix-macro: The ugly-tiny-infix-macro system

U
ugly-tiny-infix-macro: The ugly-tiny-infix-macro system
ugly-tiny-infix-macro: The ugly-tiny-infix-macro package

Jump to:   C   M   P   S   U