The lisp-preprocessor Reference Manual

Table of Contents

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

The lisp-preprocessor Reference Manual

This is the lisp-preprocessor Reference Manual, generated automatically by Declt version 3.0 "Montgomery Scott" on Fri Jun 26 11:38:58 2020 GMT+0.


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

1 Introduction

Lisp Preprocessor

Common Lisp embedded template engine

Usage

input

#include <stdio.h>

int main(void) {
    #{ :indent
    (loop :for i :from 0 :below 10
          :do (format t "printf(\"Loop: %d\", ~D);~%" i)) #}
    return 0;
}

compile

(lisp-preprocessor:run-template-into-file #p"input" #p"output")

output

#include <stdio.h>

int main(void) {
    printf("Loop: %d", 0);
    printf("Loop: %d", 1);
    printf("Loop: %d", 2);
    printf("Loop: %d", 3);
    printf("Loop: %d", 4);
    printf("Loop: %d", 5);
    printf("Loop: %d", 6);
    printf("Loop: %d", 7);
    printf("Loop: %d", 8);
    printf("Loop: %d", 9);
    return 0;
}

API

(run-template-into-stream compiland stream &rest arguments)

(run-template-into-string compiland &rest arguments)

(run-template-into-file compiland file &rest arguments)

(let ((compiland (compile-template "#{ (princ (string-capitalize $arg)) #}" :arguments '($arg))))
  (run-template-into-string compiland "test"))
; => "Test"

compiland is a string or pathname, or a compiled template function.

(compile-template text &key template-begin template-begin arguments)

* (compile-template "foo #{ (princ \"bar\") #} baz") ; => #<FUNCTION (LAMBDA (#:STREAM)) {...}>
* (run-template-into-stream * *standard-output*)
foo bar baz

* (compile-template "foo {{{ (princ \"bar\" }}} baz" :template-begin "{{{" :template-end "}}}")
* (run-template-into-stream * *standard-output*)
foo bar baz

* (run-template-into-stream (compile-template "#{ (princ (list ? ??)) #}" :arguments '(? ??)) *standard-output* "foo" "bar")
(foo bar)

Syntax

#{ template #}

indent

Keep indentation of start position

#{ :indent [offset]
...
#}
// input
int main(void) {
    #{ :indent
    (loop :for i :from 0 :below 10
          :do (format t "printf(\"Loop: %d\", ~D);~%" i)) #}
    return 0;
}

// output
int main(void) {
    printf("Loop: %d", 0);
    printf("Loop: %d", 1);
    printf("Loop: %d", 2);
    printf("Loop: %d", 3);
    printf("Loop: %d", 4);
    printf("Loop: %d", 5);
    printf("Loop: %d", 6);
    printf("Loop: %d", 7);
    printf("Loop: %d", 8);
    printf("Loop: %d", 9);
    return 0;
}

chop

Chop whitespace before and after the template

#{ :chop #}
;;; input
(defun foo (#{ (format t "~{~(~A~)~^ ~}" (loop :for symbol :in '(a b c) :collect symbol)) #}
            #{ :chop #}
            #{ (format t " ~{~(~A~)~^ ~}" (loop :for symbol :in '(x y z) :collect symbol)) #})
  (values a b c x y z))

;;; output
(defun foo (a b c x y z)
  (values a b c x y z))

License

MIT


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 lisp-preprocessor

Author

cxxxr

License

MIT

Description

Common Lisp embedded template engine

Dependencies
Source

lisp-preprocessor.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 lisp-preprocessor.asd

Location

lisp-preprocessor.asd

Systems

lisp-preprocessor (system)


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

3.1.2 lisp-preprocessor/packages.lisp

Parent

lisp-preprocessor (system)

Location

packages.lisp

Packages

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

3.1.3 lisp-preprocessor/stream.lisp

Dependency

packages.lisp (file)

Parent

lisp-preprocessor (system)

Location

stream.lisp

Exported Definitions
Internal Definitions

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

3.1.4 lisp-preprocessor/lisp-preprocessor.lisp

Dependency

stream.lisp (file)

Parent

lisp-preprocessor (system)

Location

lisp-preprocessor.lisp

Exported Definitions
Internal Definitions

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

4 Packages

Packages are listed by definition order.


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

4.1 lisp-preprocessor.in-template

Source

packages.lisp (file)

Use List
Exported Definitions

with-indent (macro)

Internal Definitions

invoke-with-indent (function)


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

4.2 lisp-preprocessor

Source

packages.lisp (file)

Use List
Exported Definitions
Internal Definitions

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

4.3 lisp-preprocessor.stream

Source

packages.lisp (file)

Use List
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: *in-template-package*
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)


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

5.1.2 Macros

Macro: with-indent INDENT &body BODY
Package

lisp-preprocessor.in-template

Source

lisp-preprocessor.lisp (file)

Macro: with-indent EMITTER INDENT &body BODY
Package

lisp-preprocessor.stream

Source

stream.lisp (file)


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

5.1.3 Functions

Function: compile-template STRING-OR-PATHNAME &key (TEMPLATE-BEGIN *TEMPLATE-BEGIN*) (TEMPLATE-END *TEMPLATE-END*) (IN-TEMPLATE-PACKAGE *IN-TEMPLATE-PACKAGE*) ARGUMENTS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: run-template-into-file COMPILAND FILE &rest ARGUMENTS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: run-template-into-stream COMPILAND STREAM &rest ARGUMENTS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: run-template-into-string COMPILAND &rest ARGUMENTS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)


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

5.1.4 Classes

Class: emitter ()
Package

lisp-preprocessor.stream

Source

stream.lisp (file)

Direct superclasses

fundamental-output-stream (class)

Direct methods
  • stream-line-column (method)
  • stream-fresh-line (method)
  • stream-write-string (method)
  • stream-write-char (method)
  • stream-element-type (method)
  • emitter-stream (method)
  • emitter-indent (method)
  • emitter-indent (method)
  • emitter-column (method)
  • emitter-column (method)
Direct slots
Slot: column
Initform

0

Readers

emitter-column (generic function)

Writers

(setf emitter-column) (generic function)

Slot: indent
Initform

0

Readers

emitter-indent (generic function)

Writers

(setf emitter-indent) (generic function)

Slot: stream
Initargs

:stream

Initform

*standard-output*

Readers

emitter-stream (generic function)


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

5.2 Internal definitions


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

5.2.1 Special variables

Special Variable: *template-begin*
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Special Variable: *template-end*
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Special Variable: +tab-width+
Package

lisp-preprocessor.stream

Source

stream.lisp (file)

Special Variable: +whitespaces+
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)


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

5.2.2 Functions

Function: add-character-width CHARACTER COLUMN
Package

lisp-preprocessor.stream

Source

stream.lisp (file)

Function: begin+ POS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: blank-line-p TEXT POS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: call-with-indent EMITTER INDENT FUNCTION
Package

lisp-preprocessor.stream

Source

stream.lisp (file)

Function: chop-in-forms FORMS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: compute-column TEXT POS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: empty-string-p STRING
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: end+ POS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: end-of-line-p TEXT POS
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: ensure-compiled-template COMPILAND
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: invoke-with-indent INDENT FUNCTION
Package

lisp-preprocessor.in-template

Source

lisp-preprocessor.lisp (file)

Function: load-template STRING-OR-PATHNAME
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: read-template-form STREAM TEXT COLUMN
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)

Function: reintern-symbol SYMBOL
Package

lisp-preprocessor

Source

lisp-preprocessor.lisp (file)


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

5.2.3 Generic functions

Generic Function: emitter-column OBJECT
Generic Function: (setf emitter-column) NEW-VALUE OBJECT
Package

lisp-preprocessor.stream

Methods
Method: emitter-column (EMITTER emitter)

automatically generated reader method

Source

stream.lisp (file)

Method: (setf emitter-column) NEW-VALUE (EMITTER emitter)

automatically generated writer method

Source

stream.lisp (file)

Generic Function: emitter-indent OBJECT
Generic Function: (setf emitter-indent) NEW-VALUE OBJECT
Package

lisp-preprocessor.stream

Methods
Method: emitter-indent (EMITTER emitter)

automatically generated reader method

Source

stream.lisp (file)

Method: (setf emitter-indent) NEW-VALUE (EMITTER emitter)

automatically generated writer method

Source

stream.lisp (file)

Generic Function: emitter-stream OBJECT
Package

lisp-preprocessor.stream

Methods
Method: emitter-stream (EMITTER emitter)

automatically generated reader method

Source

stream.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L  
Index Entry  Section

F
File, Lisp, lisp-preprocessor.asd: The lisp-preprocessor․asd file
File, Lisp, lisp-preprocessor/lisp-preprocessor.lisp: The lisp-preprocessor/lisp-preprocessor․lisp file
File, Lisp, lisp-preprocessor/packages.lisp: The lisp-preprocessor/packages․lisp file
File, Lisp, lisp-preprocessor/stream.lisp: The lisp-preprocessor/stream․lisp file

L
Lisp File, lisp-preprocessor.asd: The lisp-preprocessor․asd file
Lisp File, lisp-preprocessor/lisp-preprocessor.lisp: The lisp-preprocessor/lisp-preprocessor․lisp file
Lisp File, lisp-preprocessor/packages.lisp: The lisp-preprocessor/packages․lisp file
Lisp File, lisp-preprocessor/stream.lisp: The lisp-preprocessor/stream․lisp file
lisp-preprocessor.asd: The lisp-preprocessor․asd file
lisp-preprocessor/lisp-preprocessor.lisp: The lisp-preprocessor/lisp-preprocessor․lisp file
lisp-preprocessor/packages.lisp: The lisp-preprocessor/packages․lisp file
lisp-preprocessor/stream.lisp: The lisp-preprocessor/stream․lisp file

Jump to:   F   L  

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

A.2 Functions

Jump to:   (  
A   B   C   E   F   G   I   L   M   R   W  
Index Entry  Section

(
(setf emitter-column): Internal generic functions
(setf emitter-column): Internal generic functions
(setf emitter-indent): Internal generic functions
(setf emitter-indent): Internal generic functions

A
add-character-width: Internal functions

B
begin+: Internal functions
blank-line-p: Internal functions

C
call-with-indent: Internal functions
chop-in-forms: Internal functions
compile-template: Exported functions
compute-column: Internal functions

E
emitter-column: Internal generic functions
emitter-column: Internal generic functions
emitter-indent: Internal generic functions
emitter-indent: Internal generic functions
emitter-stream: Internal generic functions
emitter-stream: Internal generic functions
empty-string-p: Internal functions
end+: Internal functions
end-of-line-p: Internal functions
ensure-compiled-template: Internal functions

F
Function, add-character-width: Internal functions
Function, begin+: Internal functions
Function, blank-line-p: Internal functions
Function, call-with-indent: Internal functions
Function, chop-in-forms: Internal functions
Function, compile-template: Exported functions
Function, compute-column: Internal functions
Function, empty-string-p: Internal functions
Function, end+: Internal functions
Function, end-of-line-p: Internal functions
Function, ensure-compiled-template: Internal functions
Function, invoke-with-indent: Internal functions
Function, load-template: Internal functions
Function, read-template-form: Internal functions
Function, reintern-symbol: Internal functions
Function, run-template-into-file: Exported functions
Function, run-template-into-stream: Exported functions
Function, run-template-into-string: Exported functions

G
Generic Function, (setf emitter-column): Internal generic functions
Generic Function, (setf emitter-indent): Internal generic functions
Generic Function, emitter-column: Internal generic functions
Generic Function, emitter-indent: Internal generic functions
Generic Function, emitter-stream: Internal generic functions

I
invoke-with-indent: Internal functions

L
load-template: Internal functions

M
Macro, with-indent: Exported macros
Macro, with-indent: Exported macros
Method, (setf emitter-column): Internal generic functions
Method, (setf emitter-indent): Internal generic functions
Method, emitter-column: Internal generic functions
Method, emitter-indent: Internal generic functions
Method, emitter-stream: Internal generic functions

R
read-template-form: Internal functions
reintern-symbol: Internal functions
run-template-into-file: Exported functions
run-template-into-stream: Exported functions
run-template-into-string: Exported functions

W
with-indent: Exported macros
with-indent: Exported macros

Jump to:   (  
A   B   C   E   F   G   I   L   M   R   W  

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

A.3 Variables

Jump to:   *   +  
C   I   S  
Index Entry  Section

*
*in-template-package*: Exported special variables
*template-begin*: Internal special variables
*template-end*: Internal special variables

+
+tab-width+: Internal special variables
+whitespaces+: Internal special variables

C
column: Exported classes

I
indent: Exported classes

S
Slot, column: Exported classes
Slot, indent: Exported classes
Slot, stream: Exported classes
Special Variable, *in-template-package*: Exported special variables
Special Variable, *template-begin*: Internal special variables
Special Variable, *template-end*: Internal special variables
Special Variable, +tab-width+: Internal special variables
Special Variable, +whitespaces+: Internal special variables
stream: Exported classes

Jump to:   *   +  
C   I   S  

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

A.4 Data types

Jump to:   C   E   L   P   S  
Index Entry  Section

C
Class, emitter: Exported classes

E
emitter: Exported classes

L
lisp-preprocessor: The lisp-preprocessor system
lisp-preprocessor: The lisp-preprocessor package
lisp-preprocessor.in-template: The lisp-preprocessor․in-template package
lisp-preprocessor.stream: The lisp-preprocessor․stream package

P
Package, lisp-preprocessor: The lisp-preprocessor package
Package, lisp-preprocessor.in-template: The lisp-preprocessor․in-template package
Package, lisp-preprocessor.stream: The lisp-preprocessor․stream package

S
System, lisp-preprocessor: The lisp-preprocessor system

Jump to:   C   E   L   P   S