]> ruin.nu Git - proglang.git/commitdiff
needed
authorMichael Andreen <harv@ruin.nu>
Fri, 24 Feb 2006 12:05:14 +0000 (12:05 +0000)
committerMichael Andreen <harv@ruin.nu>
Fri, 24 Feb 2006 12:05:14 +0000 (12:05 +0000)
Docsyntax.tex [new file with mode: 0644]

diff --git a/Docsyntax.tex b/Docsyntax.tex
new file mode 100644 (file)
index 0000000..b22e544
--- /dev/null
@@ -0,0 +1,155 @@
+\batchmode
+%This Latex file is machine-generated by the BNF-converter
+
+\documentclass[a4paper,11pt]{article}
+\author{BNF-converter}
+\title{The Language syntax}
+\setlength{\parindent}{0mm}
+\setlength{\parskip}{1mm}
+\begin{document}
+
+\maketitle
+
+\newcommand{\emptyP}{\mbox{$\epsilon$}}
+\newcommand{\terminal}[1]{\mbox{{\texttt {#1}}}}
+\newcommand{\nonterminal}[1]{\mbox{$\langle \mbox{{\sl #1 }} \! \rangle$}}
+\newcommand{\arrow}{\mbox{::=}}
+\newcommand{\delimit}{\mbox{$|$}}
+\newcommand{\reserved}[1]{\mbox{{\texttt {#1}}}}
+\newcommand{\literal}[1]{\mbox{{\texttt {#1}}}}
+\newcommand{\symb}[1]{\mbox{{\texttt {#1}}}}
+
+This document was automatically generated by the {\em BNF-Converter}. It was generated together with the lexer, the parser, and the abstract syntax module, which guarantees that the document matches with the implementation of the language (provided no hand-hacking has taken place).
+
+\section*{The lexical structure of syntax}
+\subsection*{Identifiers}
+Identifiers \nonterminal{Ident} are unquoted strings beginning with a letter,
+followed by any combination of letters, digits, and the characters {\tt \_ '},
+reserved words excluded.
+
+
+\subsection*{Literals}
+Integer literals \nonterminal{Int}\ are nonempty sequences of digits.
+
+
+
+
+\subsection*{Reserved words and symbols}
+The set of reserved words is the set of terminals appearing in the grammar. Those reserved words that consist of non-letter characters are called symbols, and they are treated in a different way from those that are similar to identifiers. The lexer follows rules familiar from languages like Haskell, C, and Java, including longest match and spacing conventions.
+
+The reserved words used in syntax are the following: \\
+
+\begin{tabular}{lll}
+{\reserved{bool}} &{\reserved{else}} &{\reserved{false}} \\
+{\reserved{if}} &{\reserved{int}} &{\reserved{print}} \\
+{\reserved{readBool}} &{\reserved{readInt}} &{\reserved{true}} \\
+{\reserved{while}} & & \\
+\end{tabular}\\
+
+The symbols used in syntax are the following: \\
+
+\begin{tabular}{lll}
+{\symb{{$=$}}} &{\symb{;}} &{\symb{\{}} \\
+{\symb{\}}} &{\symb{(}} &{\symb{)}} \\
+{\symb{{$+$}{$+$}}} &{\symb{{$-$}{$-$}}} &{\symb{{$-$}}} \\
+{\symb{{$<$}}} &{\symb{{$<$}{$=$}}} &{\symb{{$>$}}} \\
+{\symb{{$>$}{$=$}}} &{\symb{{$=$}{$=$}}} &{\symb{!{$=$}}} \\
+{\symb{{$+$}}} &{\symb{*}} &{\symb{/}} \\
+\end{tabular}\\
+
+\subsection*{Comments}
+Single-line comments begin with {\symb{//}}. \\Multiple-line comments are  enclosed with {\symb{/*}} and {\symb{*/}}.
+
+\section*{The syntactic structure of syntax}
+Non-terminals are enclosed between $\langle$ and $\rangle$. 
+The symbols  {\arrow}  (production),  {\delimit}  (union) 
+and {\emptyP} (empty rule) belong to the BNF notation. 
+All other symbols are terminals.\\
+
+\begin{tabular}{lll}
+{\nonterminal{Bool}} & {\arrow}  &{\terminal{true}}  \\
+ & {\delimit}  &{\terminal{false}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Stm}} & {\arrow}  &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}}  \\
+ & {\delimit}  &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{;}}  \\
+ & {\delimit}  &{\nonterminal{Exp}} {\terminal{;}}  \\
+ & {\delimit}  &{\terminal{\{}} {\nonterminal{ListStm}} {\terminal{\}}}  \\
+ & {\delimit}  &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}}  \\
+ & {\delimit}  &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} {\terminal{else}} {\nonterminal{Stm}}  \\
+ & {\delimit}  &{\terminal{while}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}}  \\
+ & {\delimit}  &{\terminal{print}} {\nonterminal{Exp}} {\terminal{;}}  \\
+ & {\delimit}  &{\nonterminal{Stm}} {\terminal{;}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Exp}} & {\arrow}  &{\nonterminal{Exp1}} {\nonterminal{BOp}} {\nonterminal{Exp1}}  \\
+ & {\delimit}  &{\nonterminal{Exp1}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Exp1}} & {\arrow}  &{\nonterminal{Exp1}} {\nonterminal{Op1}} {\nonterminal{Exp2}}  \\
+ & {\delimit}  &{\nonterminal{Exp2}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Exp2}} & {\arrow}  &{\nonterminal{Exp2}} {\nonterminal{Op2}} {\nonterminal{Exp3}}  \\
+ & {\delimit}  &{\nonterminal{Exp3}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Exp3}} & {\arrow}  &{\nonterminal{Ident}} {\terminal{{$+$}{$+$}}}  \\
+ & {\delimit}  &{\nonterminal{Ident}} {\terminal{{$-$}{$-$}}}  \\
+ & {\delimit}  &{\nonterminal{Ident}}  \\
+ & {\delimit}  &{\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}}  \\
+ & {\delimit}  &{\nonterminal{Integer}}  \\
+ & {\delimit}  &{\terminal{{$-$}}} {\nonterminal{Exp3}}  \\
+ & {\delimit}  &{\nonterminal{Bool}}  \\
+ & {\delimit}  &{\terminal{readInt}}  \\
+ & {\delimit}  &{\terminal{readBool}}  \\
+ & {\delimit}  &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{ListStm}} & {\arrow}  &{\emptyP} \\
+ & {\delimit}  &{\nonterminal{Stm}} {\nonterminal{ListStm}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Stms}} & {\arrow}  &{\nonterminal{ListStm}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{BOp}} & {\arrow}  &{\terminal{{$<$}}}  \\
+ & {\delimit}  &{\terminal{{$<$}{$=$}}}  \\
+ & {\delimit}  &{\terminal{{$>$}}}  \\
+ & {\delimit}  &{\terminal{{$>$}{$=$}}}  \\
+ & {\delimit}  &{\terminal{{$=$}{$=$}}}  \\
+ & {\delimit}  &{\terminal{!{$=$}}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Op1}} & {\arrow}  &{\terminal{{$+$}}}  \\
+ & {\delimit}  &{\terminal{{$-$}}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Op2}} & {\arrow}  &{\terminal{*}}  \\
+ & {\delimit}  &{\terminal{/}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Op}} & {\arrow}  &{\nonterminal{Op1}}  \\
+ & {\delimit}  &{\nonterminal{Op2}}  \\
+\end{tabular}\\
+
+\begin{tabular}{lll}
+{\nonterminal{Type}} & {\arrow}  &{\terminal{int}}  \\
+ & {\delimit}  &{\terminal{bool}}  \\
+\end{tabular}\\
+
+
+
+\end{document}
+