A tiny PostScript interpreter.
It uses an ANTLR3 lexer and a Java Exception class as a form of longjmp to get out of (possibly nested) loops. There is support for most of the core language but not for graphics.
Input file:
$ cat src/main/resources/fact.ps
/factorial {
dup 0 eq {
pop 1
} {
dup 1 sub
factorial
mul
} ifelse
} def
6 factorial = %% Prints this result
10 factorial %% returns this result
Load the main
namespace:
(use 'blancas.tinypost.main)
Use runf
to run a ps file and get the resulting operand stack.
(runf "src/main/resources/fact.ps")
;; 720
;; [3628800]
Use run
to evaluate ps code and get the resulting operand stack.
(run "3 4 +")
;; [7]
- Make host program data available to ps code.
Copyright © 2013 Armando Blancas.
Licensed under the Eclipse Public License.