The textery Reference Manual

Table of Contents

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

The textery Reference Manual

This is the textery Reference Manual, version 0.2, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Apr 28 13:06:32 2020 GMT+0.


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

1 Introduction

textery

ava fox

implementation of tracery in lisp

Installation

$ git clone https://github.com/compufox/textery ~/common-lisp/textery
* (ql:quickload :textery)

Usage

Load a rule file (a normal tracery JSON file) using (load-grammar "rule.file")

If this is the first rule file loaded, it is set as the current grammar.

To expand text, use (expand "#expand# this!")

If you have multiple grammars loaded use the (with-grammar) macro to select which grammar to use:

(with-grammar "grammar2"
  (expand "#test#"))

You can pass arguments to the text to be expanded by using periods: (expand-text "#test.string-upcase#"), these can be chained together by doing (expand-text "#test.string-upcase.reverse#")

Arguments are any lisp function that can handle at least one string parameter. You can even provide your own!

If you want to use functions that require more than one parameter do as follows:

(defun example-argument (text param param2)
  (concatenate 'string
			   text
			   param
			   param2))

(expand "#test.example-argument(5,test)#")

API

(load-grammar file)

loads grammar from FILE

stores the contents internally under the FILE's name minus the extension

if this is the first grammar thats loaded, set our current grammar to it


(load-grammar-directory dir)

loads all grammars from directory DIR


(create-grammar name grammar)

manually creates a grammar using NAME and GRAMMAR

GRAMMAR is a tracery-formatted json string


(with-grammar grammar &body body)

executes BODY with GRAMMAR set to be the current grammar

GRAMMAR is the filename (minus extension) of the grammar file previous loaded


(list-grammars)

returns a list of all loaded grammars


(expand text)

expands TEXT using the current grammar


License

BSD 3-Clause


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 textery

Author

ava fox

License

BSD 3-Clause

Description

tracery lisp implementation

Version

0.2

Dependencies
Source

textery.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 textery.asd

Location

textery.asd

Systems

textery (system)


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

3.1.2 textery/package.lisp

Parent

textery (system)

Location

package.lisp

Packages

textery


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

3.1.3 textery/util.lisp

Dependency

package.lisp (file)

Parent

textery (system)

Location

util.lisp

Internal Definitions

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

3.1.4 textery/eng-modifiers.lisp

Dependency

util.lisp (file)

Parent

textery (system)

Location

eng-modifiers.lisp

Internal Definitions

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

3.1.5 textery/textery.lisp

Dependency

eng-modifiers.lisp (file)

Parent

textery (system)

Location

textery.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 textery

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: with-grammar GRAMMAR &body BODY

executes BODY with current-grammar set to GRAMMAR

Package

textery

Source

textery.lisp (file)


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

5.1.2 Functions

Function: create-grammar NAME GRAMMAR

creates a grammar from a string

NAME is a string that denotes what the grammar is to be called GRAMMAR is a string that contains tracery formatted json

Package

textery

Source

textery.lisp (file)

Function: expand TEXT

expands TEXT

Package

textery

Source

textery.lisp (file)

Function: load-grammar FILE

loads the json grammar referred to by FILE

Package

textery

Source

textery.lisp (file)

Function: load-grammar-directory DIR

loads all grammars from directory DIR

Package

textery

Source

textery.lisp (file)


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

5.2 Internal definitions


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

5.2.1 Special variables

Special Variable: *action-rules*

rules added by actions
very volatile, only used during evaluations

Package

textery

Source

textery.lisp (file)

Special Variable: *current-grammar*

current grammar being used

Package

textery

Source

textery.lisp (file)

Special Variable: *grammars*

all currently loaded grammar files

Package

textery

Source

textery.lisp (file)


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

5.2.2 Functions

Function: a WORD

puts ’a’ or ’an’ in front of WORD

Package

textery

Source

eng-modifiers.lisp (file)

Function: agetf PLACE INDICATOR &optional DEFAULT

getf but for alists

Package

textery

Source

util.lisp (file)

Function: apply-arguments TEXT ARGUMENTS

applies all ARGUMENTS to TEXT

ARGUMENTS is a list of strings that refer to lisp functions

Package

textery

Source

util.lisp (file)

Function: c= CHAR &rest COMPARE

returns non-nil if CHAR is one of COMPARE characters

Package

textery

Source

util.lisp (file)

Function: ed WORD

naively applies ’ed’ to the end of WORD

Package

textery

Source

eng-modifiers.lisp (file)

Function: get-all-actions TEXT

retrieves all actions from TEXT

Package

textery

Source

util.lisp (file)

Function: get-all-symbols TEXT

retrieves all symbols from TEXT

Package

textery

Source

util.lisp (file)

Function: grammar-value KEY

returns a value from the current grammar using KEY

Package

textery

Source

textery.lisp (file)

Function: json-string-to-symbol JSON-STRING &key AS-STRING AS-KEYWORD

converts camelCase JSON-STRING to a symbol

if AS-STRING is non-nil, returns a string instead of a symbol if AS-KEYWORD is non-nil, returns a keyword

Package

textery

Source

util.lisp (file)

Function: last-letter WORD

gets last letter of WORD

Package

textery

Source

util.lisp (file)

Function: list-grammars ()

returns a list of loaded grammars

Package

textery

Source

textery.lisp (file)

Function: parse-function NAME

returns a function of name NAME

Package

textery

Source

util.lisp (file)

Function: possesive WORD

naively converts WORD into its possesive form

Package

textery

Source

eng-modifiers.lisp (file)

Function: process-actions ACTIONS TEXT

processes all ACTIONS, removing them from TEXT

Package

textery

Source

textery.lisp (file)

Function: process-symbols SYMBOLS TEXT

processes all SYMBOLS, evaluating and replacing them in TEXT

Package

textery

Source

textery.lisp (file)

Function: random-from-list LST

returns a random element from LST

Package

textery

Source

util.lisp (file)

Function: replace-first OLD NEW S

replaces the first occurance of OLD with NEW in S

if OLD isn’t found in S, returns S as-is

Package

textery

Source

util.lisp (file)

Function: s WORD

naively pluralizes WORD

Package

textery

Source

eng-modifiers.lisp (file)

Function: vowel-p CHAR

returns non-nil is CHAR is a vowel

Package

textery

Source

util.lisp (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   T  
Index Entry  Section

F
File, Lisp, textery.asd: The textery․asd file
File, Lisp, textery/eng-modifiers.lisp: The textery/eng-modifiers․lisp file
File, Lisp, textery/package.lisp: The textery/package․lisp file
File, Lisp, textery/textery.lisp: The textery/textery․lisp file
File, Lisp, textery/util.lisp: The textery/util․lisp file

L
Lisp File, textery.asd: The textery․asd file
Lisp File, textery/eng-modifiers.lisp: The textery/eng-modifiers․lisp file
Lisp File, textery/package.lisp: The textery/package․lisp file
Lisp File, textery/textery.lisp: The textery/textery․lisp file
Lisp File, textery/util.lisp: The textery/util․lisp file

T
textery.asd: The textery․asd file
textery/eng-modifiers.lisp: The textery/eng-modifiers․lisp file
textery/package.lisp: The textery/package․lisp file
textery/textery.lisp: The textery/textery․lisp file
textery/util.lisp: The textery/util․lisp file

Jump to:   F   L   T  

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

A.2 Functions

Jump to:   A   C   E   F   G   J   L   M   P   R   S   V   W  
Index Entry  Section

A
a: Internal functions
agetf: Internal functions
apply-arguments: Internal functions

C
c=: Internal functions
create-grammar: Exported functions

E
ed: Internal functions
expand: Exported functions

F
Function, a: Internal functions
Function, agetf: Internal functions
Function, apply-arguments: Internal functions
Function, c=: Internal functions
Function, create-grammar: Exported functions
Function, ed: Internal functions
Function, expand: Exported functions
Function, get-all-actions: Internal functions
Function, get-all-symbols: Internal functions
Function, grammar-value: Internal functions
Function, json-string-to-symbol: Internal functions
Function, last-letter: Internal functions
Function, list-grammars: Internal functions
Function, load-grammar: Exported functions
Function, load-grammar-directory: Exported functions
Function, parse-function: Internal functions
Function, possesive: Internal functions
Function, process-actions: Internal functions
Function, process-symbols: Internal functions
Function, random-from-list: Internal functions
Function, replace-first: Internal functions
Function, s: Internal functions
Function, vowel-p: Internal functions

G
get-all-actions: Internal functions
get-all-symbols: Internal functions
grammar-value: Internal functions

J
json-string-to-symbol: Internal functions

L
last-letter: Internal functions
list-grammars: Internal functions
load-grammar: Exported functions
load-grammar-directory: Exported functions

M
Macro, with-grammar: Exported macros

P
parse-function: Internal functions
possesive: Internal functions
process-actions: Internal functions
process-symbols: Internal functions

R
random-from-list: Internal functions
replace-first: Internal functions

S
s: Internal functions

V
vowel-p: Internal functions

W
with-grammar: Exported macros

Jump to:   A   C   E   F   G   J   L   M   P   R   S   V   W  

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

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*action-rules*: Internal special variables
*current-grammar*: Internal special variables
*grammars*: Internal special variables

S
Special Variable, *action-rules*: Internal special variables
Special Variable, *current-grammar*: Internal special variables
Special Variable, *grammars*: Internal special variables

Jump to:   *  
S  

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

A.4 Data types

Jump to:   P   S   T  
Index Entry  Section

P
Package, textery: The textery package

S
System, textery: The textery system

T
textery: The textery system
textery: The textery package

Jump to:   P   S   T