#-d
#-E
%^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, Marc Seutter}
\title{Parser for Glass}
\makeindex
\begin{document}
\maketitle
\subsection{glass text }
Origens are of the form ("file", line), so we first surround the current
file name with double quotes.
Then reserved identifiers (keywords) are stored in a table to be able to 
check on reserved identfiers.
A glass text is a sequence of glass text elements.
Initialy we begin the translation with an empty identation.
The translation of the elements are stored together in a list.
%     
glass text (MY ID + "["+glass elts+"]\n">):
      get line file (line>,file>),
      set line file (>line,>quote+file+quote),
      reserved,
      layout,
      glass text elements (>empty, glass elts>).

glass text elements (>indent, glass elt+glass elts>):
   glass text element (>indent, glass elt>),->,
     more glass text elements (>indent,glass elts>);
glass text elements (>indent, empty>):
   end of sentence.


more glass text elements (>indent,glass elts>):
     semicolons,
       yet more glass text elements (>indent, glass elts>), ->;
more glass text elements (>indent, empty>):
     opt semicolons, end of sentence.

yet more glass text elements (>indent,","+glass elt+glass elts>):
      glass text element (>indent, glass elt>), 
        more glass text elements (>indent, glass elts>),->;
yet more glass text elements (>indent,empty>):
     end of sentence. 

%ERROR RECOVERY DELETED
yet more glass text elements (>indent,empty>):
      recover.

recover:
   error message (x>),
   type out (>x),
   synchronize,
   more glass text elements (>empty, _>).

synchronize:
   ^!;!*, more synchronize.

more synchronize:
   ? def keyword, ->;
more synchronize:
    ";", synchronize.
def keyword:
   semicolons,
   more def keyword.

more def keyword:
   ?keyword (>"DEF"), ->;
more def keyword:
   ?keyword (>"BASETYPE"), ->;
more def keyword:
   ?keyword (>"ATOM"), ->;
more def keyword:
   ?keyword (>"MAC").
ENDRECOVER%

%TEX
Because we will not allow a glass text element to produce empty,
otherwise the (empty) result of empty elements should be filtered out later
to produce a valid miranda data structure, 
and a flexible placement of semicolons is desired we skip all semicons immediate.
%

semicolons: 
   semicolon symbol,  opt semicolons.

opt semicolons:
   semicolon symbol,  opt semicolons, ->;
opt semicolons:.

%TEX
\subsection{ glass text element }

%
glass text element (>indent, atom decls>):
   atom declarations (>indent, atom decls>), ->;
glass text element (>indent, def>):
   def (>indent, def>), ->;
glass text element (>indent, mac>):
   mac (>indent, mac>), ->;
glass text element (>indent, type decls>):
   type naming (>indent, type decls>), ->;
glass text element (>indent, atomic type decls>):
   base type declarations (>indent, atomic type decls>).


%TEX
\subsection{ Base type declarations }
%

base type declarations (>indent, decls>):
   base type symbol, base type decls (>indent, decls>).

base type decls (>indent, decl+decls>):
   base type decl (>indent, decl>), 
     more  base type decls (>indent, decls>).

more  base type decls (>indent, ","+decls>):
   comma symbol, ->,
      base type decls (>indent, decls>);
more base type decls (>indent, empty>):.

base type decl (>indent, nlcr+indent+"(DefTyp "+ org + name+ " (TypAtom "+name+"))">):
   get org (org>),
   name (name>).

%TEX
\subsection{ type naming }
%
type naming (>indent, nams>):
   type symbol, typnamings (>indent, nams>).

typnamings (>indent, nam+nams>):
   typnaming (>indent, nam>), 
      more typnamings (>indent, nams>).
