Aescm can preprocess an interpreter language if it satisfies the following conditions:
\"means " and
\\\ in a string;
\nmeans a newline in a string;
In short, most scripting languages will do. The tarball of this version (0.30) contains the configuration files for Awk, Csh, Common Lisp, Perl, Python, Ruby, Sh, Tcl and of course Scheme. I will describe the syntax of configuration files below.
Aescm and the original escm send code to its backend interpreter through a pipe. It is ideal if your favorite interpreter works as filter by default. But it is not always the case. So you must find out command line options to prevent from printing prompts and evaluated values.
The first test must print string.
echo '(display "string")' | env -i /usr/local/bin/scheme -options
The second test must print nothing.
echo '"string"' | env -i /usr/local/bin/scheme -options
The command line options for some popular Schme and Common Lisp implementations are listed in doc/interpreter.html.
Information on your interpreter language is read from a simple configuration file, about a dozen of lines at most. The upper limit of the size is 511B.
This distribution comes with configuration files for
Awk, C Shell, Common Lisp, Perl, Python, Rugy, Schem, Shell, and Tcl.
They are stored in $(pkgdatadir)/lang
(maybe in /usr/local/share/aescm/lang/
).
Here are those for Awk and Scheme:
# awk - configurations for the Awk language awk -f /dev/stdin # init BEGIN { # assign @VAR@ = @VAL@; # string printf "@STR@"; # display printf (@EXP@); # finish exit; }
;; scm - configurations for the Scheme language gosh -b ;; identifier *lisp* ;; nil #f ;; bind (define @VAR@ @VAL@) ;; assign (set! @VAR@ @VAL@) ;; string (display "@STR@") ;; display (display @EXP@) ;; newline (newline)
The first character of a configuration file is the leading character. A line beginning with this character is used to separate records. It will be convenient if it is the first comment character of your favorite interpreter language.
You must specify the namespacein the second line as
<?namesapace ...>
.
The first line of a record starts with the leading character. The first line's second field is the keyword for the record. The following lines are data.
These are the keywords:
The interpreter and its arguments. In most cases, your interpreter will need no arguments, for it may be sophistiacated enough to switch to a batch mode if stdin is connected to a pipe.
The initialization code. This record is optional.
Naming convention of idenfiers or variables. This should be one of *lisp*, UPPER, Title and lower. The default is lower.
An object to be used as false. This record is optional. If it is omitted, an empty string "" is used.
Code to bind a variable @VAR@ to a value @VAL@. This record is optional. If it is omitted, @VAR@ is assigned to @VAL@.
Code to assign a value @VAL@ to a variable @VAR@. This record is obligatory.
Code to print a string "@STR@". This record is obligatory.
Code to send the external representation of an expression @EXP@. This record is optional. If it is omitted, you cannot use :d subspace.
Code to send a newline.
This record is optional.
If it is omitted, \n
is added to strings.
The finalization code. This record is optional.