#-d
%^TEX
\documentstyle[glammar]{article}
\topmargin      0 mm
\headheight     0 mm
\headsep        0 mm
\textheight     240 mm
\footskip       7 mm
\footheight     11 mm

\oddsidemargin  0 mm
\evensidemargin 0 mm
\textwidth      159.2 mm
\author{Eric Voss}
\title{Glass Macro Expander}
\makeindex
\begin{document}
\maketitle

\section{Main.} 
Expansion is done in the order:
\begin{enumerate}
\item
Parsing of the text representated data structure generating a new
{\sc glammar} data structure.
Also a global symbol table is maintained.
This table contains references to macro definitions,atom definitions, parameterized def definitions.

\item
Transforming the data structure according to the specification rules.

\item
Printing and checking of the data structure (only kernel structures are alowed).

\end{enumerate}
%

parse expand and print (MY ID + show glass ds + N>): 
    layout,
    init  connection to dc,
    scan glass (ds>), 
    end of sentence,
    trans glass (>ds ,>ds ),
    walk glass (>N, >ds , show glass ds>).


%TEX
\section{Trans glass ds.} 

Transformation rules (rule names starting with the name {\em trans})
 as generated from {\tt mixedgl.ds}.
Addapted to meet the specifications.
%
  
%TEX
Macros and parameterized definition do not occur in 
the kernel language.
It is not nessecary to apply the transformation 
function to them.
In the specification it is assumed that they 
are deleted so that is what we will do.
%
remove macros and par defs (>empty,empty>): ->;
remove macros and par defs (>mac*rest,filtered list>):
    is macro or par def (>mac), ->,
    remove macros and par defs (>rest,filtered list>);
remove macros and par defs (>def*rest, def*filtered list>):
    remove macros and par defs (>rest, filtered list>).

is macro or par def (>defv): 
    where (>defv ,def val *val orig * val name * type >),
    where (>type, vtype*typecs * mac alts  V mac lambda>),
    more is mac or par def (>mac alts V mac lambda).

more is mac or par def (>VMacLambda*_): ->;
more is mac or par def ( >VMacAlts*LIST*f*r):.


%TEX
Begin the transformation at the top node.
This node points to a definition list.
%
trans glass (> node,> glass):
	trans def list (> glass, >glass).


%TEX
Though  macros and parameterized definitions are removed 
from the top list they can still be present locally.
%
trans def(> node, > DefVal * valorig* defval* type):
        where (>type, vtype*typecs * mac alts  V mac lambda>),
        more is mac or par def (>mac alts V mac lambda), ->,
	trans val (> type, >type, >empty);
%TEX
In Atoms, Basetypes and Defs first the body is expanded and 
then the head node is updated
%
trans def(> node, > DefVal * valorig* defval* valas): 
	trans val (> valas, >valas, >empty),
        defval(>node,>valas), ->;
trans def(> node, > DefCon * conorig* defcon* conas): ->,
	trans val (> defcon, >defcon,>empty),
	trans val (> conas, >conas,>empty);
trans def(> node, > DefTyp * typorig* deftyp* typas): ->,
	def typ (> node, > typorig, >deftyp, > typas);
%TEX
These are kernel constructors so expansion is already done.
%
trans def (> constant,> DefAtom): ->;
trans def (> constant,> DefBasetype): ->;
trans def (> constant,> DefErr): .


