Using Aescm with Another Computer Language

  1. Interpreter Language
  2. Backend Interpreter
  3. Configuration File Format

Interpreter Language

Aescm can preprocess an interpreter language if it satisfies the following conditions:

  1. a string is bracketted between two "s;
  2. \" means " and \\ \ in a string;
  3. it has a procedure to write out a string without adding newline;
  4. it has a procedure to send a newline or \n means a newline in a string;
  5. the variable is placed before the value in a binding statement;
  6. commands are processed in order.

In short, most scripting languages will do. The tarball of this version (0.31) 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.

Backend Interpreter

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.

Configuration File Format

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 {
# bind
@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@)
;; string
(display "@STR@")
;; display
(display @EXP@)
;; newline
(newline)

Leading Character and Namespace

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

Other Records

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:

command

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.

intialization

The initialization code. This record is optional.

identifer

Naming convention of idenfiers or variables. This should be one of *lisp*, UPPER, Title and lower. The default is lower.

nil

An object to be used as false. This record is optional. If it is omitted, an empty string "" is used.

bind

Code to bind a variable @VAR@ to a value @VAL@. This record is obligatory.

string

Code to print a string "@STR@". This record is obligatory.

expression

Code to send the external representation of an expression @EXP@. This record is optional. If it is omitted, you cannot use :d subspace.

newline

Code to send a newline. This record is optional. If it is omitted, \n is added to strings.

finalization

The finalization code. This record is optional.


SourceForge.net Logo