Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the polisher Reference Manual, version 0.1, generated automatically by Declt version 3.0 "Montgomery Scott" on Sun May 15 05:49:57 2022 GMT+0.
• Introduction | What polisher is all about | |
• Systems | The systems documentation | |
• Modules | The modules documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
Infix notation to S-expression (Polish notation) translator for Common Lisp
Formulae inside the reader macro #i{ ... }
are interpreted as infix notation.
If you don't want to use it, the macro polish
is available instead.
(polisher:activate-infix-syntax) ; Activate #i{ ... } reader macro
#i{1+2*3}
;=> 7
(polisher:polish "1+2*3") ; Exactly the same as the above one
;=> 7
#i{1 + 2*3} ; Spaces can be inserted anywhere
;=> 7
#i{2*3/4}
;=> 3/2
#i{2**2**3} ; Identical to 2**(2**3), not (2**2)**3
;=> 256
#i{atan(1.0d0, 1.0d0)}
;=> 0.7853981633974483d0
(flet ((add1 (x) (+ x 1)))
#i{add1(2)+3})
;=> 6
(defparameter *some-global-value* 1.5) ; The symbol containg operator charcters
#i{1 + 2 * "*some-global-value*"} ; must be double-quoted
;=> 4.0
#i{2*#c(1 2)+3}
;=> #C(5 4)
#i{#b101 +3} ; Some spaces are needed after #b101
;=> 8
If you already have Quicklisp client, just run the following:
(ql:quickload :polisher)
It will resolve dependencies automatically.
(ql:register-local-projects)
.(ql:quickload :polisher)
anywhere.(asdf:load-system :polisher)
.Following operators are defined by default:
| symbol | function | priority | left associative | |--------|----------|----------|------------------| | + | + | 1 | t | | - | - | 1 | t | | * | * | 2 | t | | / | / | 2 | t | | ** | expt | 3 | nil |
(polisher:add-operator (make-instance 'polisher:operator
:symbol '^
:function 'expt
:priority 3
:left-associative nil))
#i{2^2^3}
;=> 256
Note that if there are left-associative operators and right-associative operators
both having the same priority, formulae can't be evaluated correctly.
For example, when op1
is left-associative and op2
is right-associative,
x op1 y op2 z
can be interpreted as either (x op1 y) op2 z
and
x op1 (y op2 z)
.
When you add your own operator, be careful of which package its symbol is interned in.
Symbols which start with numbers must be double-quoted. The following example shows the reason:
(let ((1e 2))
#i{1e+1+1})
;=> 11.0
(let ((1e 2))
#i{"1e"+1+1})
;=> 4
No one defines such an odd symbol? Remember the standard functions 1+
and 1-
!
Symbols whose symbol-name sandwiched in vertical bars (e.g. |ab de|
) can't be used.
This is because someone may want to use a vertical bar as the logical OR operator.
The infix formula 1+*global-symbol*
can be uniquely interpreted as (+ 1 *global-symbol*)
,
so double-quoting may be unnecessary.
However in my opinion, the formula seems very weird when it appears in ALGOL-like languages;
so I think double-quoting should be used.
In addition, many text editors highlight double-quoted things, helping us to distinguish
symbol-names from operators.
Next: Modules, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The polisher system |
mrcdr
MIT
Infix notation to S-expression translator
0.1
cl-ppcre
polisher.asd (file)
Modules are listed depth-first from the system components tree.
• The polisher/src module |
package.lisp (file)
polisher (system)
src/
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The polisher/package․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
polisher.asd
polisher (system)
Next: The polisher/src/types-svalues․lisp file, Previous: The polisher․asd file, Up: Lisp files [Contents][Index]
Next: The polisher/src/tokenizer․lisp file, Previous: The polisher/package․lisp file, Up: Lisp files [Contents][Index]
src (module)
src/types-svalues.lisp
Next: The polisher/src/transformer․lisp file, Previous: The polisher/src/types-svalues․lisp file, Up: Lisp files [Contents][Index]
types-svalues.lisp (file)
src (module)
src/tokenizer.lisp
Next: The polisher/src/interface․lisp file, Previous: The polisher/src/tokenizer․lisp file, Up: Lisp files [Contents][Index]
tokenizer.lisp (file)
src (module)
src/transformer.lisp
Previous: The polisher/src/transformer․lisp file, Up: Lisp files [Contents][Index]
transformer.lisp (file)
src (module)
src/interface.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The polisher package |
package.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported macros | ||
• Exported functions | ||
• Exported classes |
Next: Exported functions, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Convert given infix-style formula into S-expression, which will be evaluated as usual lisp form.
interface.lisp (file)
Next: Exported classes, Previous: Exported macros, Up: Exported definitions [Contents][Index]
Activate infix reader-macro #i{...} by default. If the argument "activate" is nil,
deactivate (unregister) #i macro (regardless of whether or not it has been registered by this function).
The macro character "i" can be changed by the argument "dispatch-char".
interface.lisp (file)
Add infix-style operator, which should be a polisher:operator instance.
types-svalues.lisp (file)
Return information of registered operators as string.
interface.lisp (file)
Previous: Exported functions, Up: Exported definitions [Contents][Index]
Operator class, whose instance will usually be registered by polisher:add-operator function.
types-svalues.lisp (file)
standard-object (class)
Symbol used in infix-style.
(quote symbol)
:symbol
Function to be called, which must receive exactly two arguments.
:function
Operator priority. Operators will be evaluated from ones having larger priority.
(quote number)
:priority
If t, this operator will be left associative (e.g. addition operator +). If nil, this operator will be right associative (e.g. power operator **).
(quote boole)
:left-associative
t
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal macros | ||
• Internal functions | ||
• Internal generic functions |
Next: Internal macros, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
types-svalues.lisp (file)
types-svalues.lisp (file)
types-svalues.lisp (file)
types-svalues.lisp (file)
types-svalues.lisp (file)
Next: Internal functions, Previous: Internal special variables, Up: Internal definitions [Contents][Index]
tokenizer.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
tokenizer.lisp (file)
transformer.lisp (file)
interface.lisp (file)
tokenizer.lisp (file)
transformer.lisp (file)
transformer.lisp (file)
interface.lisp (file)
tokenizer.lisp (file)
transformer.lisp (file)
types-svalues.lisp (file)
tokenizer.lisp (file)
transformer.lisp (file)
Previous: Internal functions, Up: Internal definitions [Contents][Index]
types-svalues.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L M P |
---|
Jump to: | F L M P |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | A C F G I L M P R S T |
---|
Jump to: | A C F G I L M P R S T |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
F L P S |
---|
Jump to: | *
F L P S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C O P S |
---|
Jump to: | C O P S |
---|