]> ruin.nu Git - proglang.git/blob - Docsyntax.tex
YEAH
[proglang.git] / Docsyntax.tex
1 \batchmode
2 %This Latex file is machine-generated by the BNF-converter
3
4 \documentclass[a4paper,11pt]{article}
5 \author{BNF-converter}
6 \title{The Language syntax}
7 \setlength{\parindent}{0mm}
8 \setlength{\parskip}{1mm}
9 \begin{document}
10
11 \maketitle
12
13 \newcommand{\emptyP}{\mbox{$\epsilon$}}
14 \newcommand{\terminal}[1]{\mbox{{\texttt {#1}}}}
15 \newcommand{\nonterminal}[1]{\mbox{$\langle \mbox{{\sl #1 }} \! \rangle$}}
16 \newcommand{\arrow}{\mbox{::=}}
17 \newcommand{\delimit}{\mbox{$|$}}
18 \newcommand{\reserved}[1]{\mbox{{\texttt {#1}}}}
19 \newcommand{\literal}[1]{\mbox{{\texttt {#1}}}}
20 \newcommand{\symb}[1]{\mbox{{\texttt {#1}}}}
21
22 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).
23
24 \section*{The lexical structure of syntax}
25 \subsection*{Identifiers}
26 Identifiers \nonterminal{Ident} are unquoted strings beginning with a letter,
27 followed by any combination of letters, digits, and the characters {\tt \_ '},
28 reserved words excluded.
29
30
31 \subsection*{Literals}
32 Integer literals \nonterminal{Int}\ are nonempty sequences of digits.
33
34
35
36
37 \subsection*{Reserved words and symbols}
38 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.
39
40 The reserved words used in syntax are the following: \\
41
42 \begin{tabular}{lll}
43 {\reserved{bool}} &{\reserved{else}} &{\reserved{false}} \\
44 {\reserved{if}} &{\reserved{int}} &{\reserved{print}} \\
45 {\reserved{readBool}} &{\reserved{readInt}} &{\reserved{true}} \\
46 {\reserved{while}} & & \\
47 \end{tabular}\\
48
49 The symbols used in syntax are the following: \\
50
51 \begin{tabular}{lll}
52 {\symb{{$=$}}} &{\symb{;}} &{\symb{\{}} \\
53 {\symb{\}}} &{\symb{(}} &{\symb{)}} \\
54 {\symb{{$+$}{$+$}}} &{\symb{{$-$}{$-$}}} &{\symb{{$-$}}} \\
55 {\symb{!}} &{\symb{{$<$}}} &{\symb{{$<$}{$=$}}} \\
56 {\symb{{$>$}}} &{\symb{{$>$}{$=$}}} &{\symb{{$=$}{$=$}}} \\
57 {\symb{!{$=$}}} &{\symb{{$+$}}} &{\symb{*}} \\
58 {\symb{/}} & & \\
59 \end{tabular}\\
60
61 \subsection*{Comments}
62 Single-line comments begin with {\symb{//}}. \\Multiple-line comments are  enclosed with {\symb{/*}} and {\symb{*/}}.
63
64 \section*{The syntactic structure of syntax}
65 Non-terminals are enclosed between $\langle$ and $\rangle$. 
66 The symbols  {\arrow}  (production),  {\delimit}  (union) 
67 and {\emptyP} (empty rule) belong to the BNF notation. 
68 All other symbols are terminals.\\
69
70 \begin{tabular}{lll}
71 {\nonterminal{Bool}} & {\arrow}  &{\terminal{true}}  \\
72  & {\delimit}  &{\terminal{false}}  \\
73 \end{tabular}\\
74
75 \begin{tabular}{lll}
76 {\nonterminal{Stm}} & {\arrow}  &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}} {\terminal{;}}  \\
77  & {\delimit}  &{\nonterminal{Type}} {\nonterminal{Ident}} {\terminal{;}}  \\
78  & {\delimit}  &{\nonterminal{Exp}} {\terminal{;}}  \\
79  & {\delimit}  &{\terminal{\{}} {\nonterminal{ListStm}} {\terminal{\}}}  \\
80  & {\delimit}  &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}}  \\
81  & {\delimit}  &{\terminal{if}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}} {\terminal{else}} {\nonterminal{Stm}}  \\
82  & {\delimit}  &{\terminal{while}} {\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} {\nonterminal{Stm}}  \\
83  & {\delimit}  &{\terminal{print}} {\nonterminal{Exp}} {\terminal{;}}  \\
84 \end{tabular}\\
85
86 \begin{tabular}{lll}
87 {\nonterminal{Exp}} & {\arrow}  &{\nonterminal{Ident}} {\terminal{{$=$}}} {\nonterminal{Exp}}  \\
88  & {\delimit}  &{\nonterminal{Exp1}} {\nonterminal{Op0}} {\nonterminal{Exp1}}  \\
89  & {\delimit}  &{\nonterminal{Exp1}}  \\
90 \end{tabular}\\
91
92 \begin{tabular}{lll}
93 {\nonterminal{Exp1}} & {\arrow}  &{\nonterminal{Exp1}} {\nonterminal{Op1}} {\nonterminal{Exp2}}  \\
94  & {\delimit}  &{\nonterminal{Exp2}}  \\
95 \end{tabular}\\
96
97 \begin{tabular}{lll}
98 {\nonterminal{Exp2}} & {\arrow}  &{\nonterminal{Exp2}} {\nonterminal{Op2}} {\nonterminal{Exp3}}  \\
99  & {\delimit}  &{\nonterminal{Exp3}}  \\
100 \end{tabular}\\
101
102 \begin{tabular}{lll}
103 {\nonterminal{Exp3}} & {\arrow}  &{\nonterminal{Ident}} {\terminal{{$+$}{$+$}}}  \\
104  & {\delimit}  &{\nonterminal{Ident}} {\terminal{{$-$}{$-$}}}  \\
105  & {\delimit}  &{\nonterminal{Ident}}  \\
106  & {\delimit}  &{\nonterminal{Integer}}  \\
107  & {\delimit}  &{\terminal{{$-$}}} {\nonterminal{Exp3}}  \\
108  & {\delimit}  &{\terminal{!}} {\nonterminal{Exp3}}  \\
109  & {\delimit}  &{\nonterminal{Bool}}  \\
110  & {\delimit}  &{\terminal{readInt}}  \\
111  & {\delimit}  &{\terminal{readBool}}  \\
112  & {\delimit}  &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}}  \\
113 \end{tabular}\\
114
115 \begin{tabular}{lll}
116 {\nonterminal{ListStm}} & {\arrow}  &{\emptyP} \\
117  & {\delimit}  &{\nonterminal{Stm}} {\nonterminal{ListStm}}  \\
118 \end{tabular}\\
119
120 \begin{tabular}{lll}
121 {\nonterminal{Stms}} & {\arrow}  &{\nonterminal{ListStm}}  \\
122 \end{tabular}\\
123
124 \begin{tabular}{lll}
125 {\nonterminal{Op0}} & {\arrow}  &{\terminal{{$<$}}}  \\
126  & {\delimit}  &{\terminal{{$<$}{$=$}}}  \\
127  & {\delimit}  &{\terminal{{$>$}}}  \\
128  & {\delimit}  &{\terminal{{$>$}{$=$}}}  \\
129  & {\delimit}  &{\terminal{{$=$}{$=$}}}  \\
130  & {\delimit}  &{\terminal{!{$=$}}}  \\
131 \end{tabular}\\
132
133 \begin{tabular}{lll}
134 {\nonterminal{Op1}} & {\arrow}  &{\terminal{{$+$}}}  \\
135  & {\delimit}  &{\terminal{{$-$}}}  \\
136 \end{tabular}\\
137
138 \begin{tabular}{lll}
139 {\nonterminal{Op2}} & {\arrow}  &{\terminal{*}}  \\
140  & {\delimit}  &{\terminal{/}}  \\
141 \end{tabular}\\
142
143 \begin{tabular}{lll}
144 {\nonterminal{Op}} & {\arrow}  &{\nonterminal{Op1}}  \\
145  & {\delimit}  &{\nonterminal{Op2}}  \\
146  & {\delimit}  &{\nonterminal{Op0}}  \\
147 \end{tabular}\\
148
149 \begin{tabular}{lll}
150 {\nonterminal{Type}} & {\arrow}  &{\terminal{int}}  \\
151  & {\delimit}  &{\terminal{bool}}  \\
152 \end{tabular}\\
153
154
155
156 \end{document}
157