diff --git a/.gitignore b/.gitignore index 0984599..fd90be9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,9 +2,10 @@ dist-newstyle *.y *.x *.bak +Grammar.tex src/Grammar language test_program_result output/ *.o -*.out \ No newline at end of file +*.out diff --git a/Grammar.pdf b/Grammar.pdf new file mode 100644 index 0000000..f7f7a70 Binary files /dev/null and b/Grammar.pdf differ diff --git a/Grammar.tex b/Grammar.tex deleted file mode 100644 index 4a16b00..0000000 --- a/Grammar.tex +++ /dev/null @@ -1,215 +0,0 @@ -%% File generated by the BNF Converter (bnfc 2.9.4.1). - -\batchmode - -\documentclass[a4paper,11pt]{article} -\usepackage[T1]{fontenc} -\usepackage[utf8x]{inputenc} -\setlength{\parindent}{0mm} -\setlength{\parskip}{1mm} - -\title{The Language Grammar} -\author{BNF-converter} - -\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 Grammar} - -\subsection*{Literals} -Character literals \nonterminal{Char}\ have the form -\terminal{'}$c$\terminal{'}, where $c$ is any single character. - -Integer literals \nonterminal{Int}\ are nonempty sequences of digits. - - - -UIdent literals are recognized by the regular expression -\({\nonterminal{upper}} (\mbox{`\_'} \mid {\nonterminal{digit}} \mid {\nonterminal{letter}})*\) - -LIdent literals are recognized by the regular expression -\({\nonterminal{lower}} (\mbox{`\_'} \mid {\nonterminal{digit}} \mid {\nonterminal{letter}})*\) - -\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 Grammar are the following: \\ - -\begin{tabular}{lll} -{\reserved{case}} &{\reserved{data}} &{\reserved{forall}} \\ -{\reserved{in}} &{\reserved{let}} &{\reserved{of}} \\ -{\reserved{where}} & & \\ -\end{tabular}\\ - -The symbols used in Grammar are the following: \\ - -\begin{tabular}{lll} -{\symb{:}} &{\symb{{$=$}}} &{\symb{(}} \\ -{\symb{)}} &{\symb{{$-$}{$>$}}} &{\symb{.}} \\ -{\symb{\{}} &{\symb{\}}} &{\symb{{$+$}}} \\ -{\symb{$\backslash$}} &{\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 Grammar} - -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{Program}} & {\arrow} &{\nonterminal{ListDef}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Def}} & {\arrow} &{\nonterminal{Bind}} \\ - & {\delimit} &{\nonterminal{Sig}} \\ - & {\delimit} &{\nonterminal{Data}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Sig}} & {\arrow} &{\nonterminal{LIdent}} {\terminal{:}} {\nonterminal{Type}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Bind}} & {\arrow} &{\nonterminal{LIdent}} {\nonterminal{ListLIdent}} {\terminal{{$=$}}} {\nonterminal{Exp}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Type1}} & {\arrow} &{\nonterminal{UIdent}} \\ - & {\delimit} &{\nonterminal{TVar}} \\ - & {\delimit} &{\nonterminal{UIdent}} {\terminal{(}} {\nonterminal{ListType}} {\terminal{)}} \\ - & {\delimit} &{\terminal{(}} {\nonterminal{Type}} {\terminal{)}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Type}} & {\arrow} &{\nonterminal{Type1}} {\terminal{{$-$}{$>$}}} {\nonterminal{Type}} \\ - & {\delimit} &{\terminal{forall}} {\nonterminal{TVar}} {\terminal{.}} {\nonterminal{Type}} \\ - & {\delimit} &{\nonterminal{Type1}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{TVar}} & {\arrow} &{\nonterminal{LIdent}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Data}} & {\arrow} &{\terminal{data}} {\nonterminal{Type}} {\terminal{where}} {\terminal{\{}} {\nonterminal{ListInj}} {\terminal{\}}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Inj}} & {\arrow} &{\nonterminal{UIdent}} {\terminal{:}} {\nonterminal{Type}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Exp4}} & {\arrow} &{\terminal{(}} {\nonterminal{Exp}} {\terminal{:}} {\nonterminal{Type}} {\terminal{)}} \\ - & {\delimit} &{\terminal{(}} {\nonterminal{Exp}} {\terminal{)}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Exp3}} & {\arrow} &{\nonterminal{LIdent}} \\ - & {\delimit} &{\nonterminal{UIdent}} \\ - & {\delimit} &{\nonterminal{Lit}} \\ - & {\delimit} &{\nonterminal{Exp4}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Exp2}} & {\arrow} &{\nonterminal{Exp2}} {\nonterminal{Exp3}} \\ - & {\delimit} &{\nonterminal{Exp3}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Exp1}} & {\arrow} &{\nonterminal{Exp1}} {\terminal{{$+$}}} {\nonterminal{Exp2}} \\ - & {\delimit} &{\nonterminal{Exp2}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Exp}} & {\arrow} &{\terminal{let}} {\nonterminal{Bind}} {\terminal{in}} {\nonterminal{Exp}} \\ - & {\delimit} &{\terminal{$\backslash$}} {\nonterminal{LIdent}} {\terminal{.}} {\nonterminal{Exp}} \\ - & {\delimit} &{\terminal{case}} {\nonterminal{Exp}} {\terminal{of}} {\terminal{\{}} {\nonterminal{ListBranch}} {\terminal{\}}} \\ - & {\delimit} &{\nonterminal{Exp1}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Lit}} & {\arrow} &{\nonterminal{Integer}} \\ - & {\delimit} &{\nonterminal{Char}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Branch}} & {\arrow} &{\nonterminal{Pattern}} {\terminal{{$=$}{$>$}}} {\nonterminal{Exp}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Pattern1}} & {\arrow} &{\nonterminal{LIdent}} \\ - & {\delimit} &{\nonterminal{Lit}} \\ - & {\delimit} &{\terminal{\_}} \\ - & {\delimit} &{\nonterminal{UIdent}} \\ - & {\delimit} &{\terminal{(}} {\nonterminal{Pattern}} {\terminal{)}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{Pattern}} & {\arrow} &{\nonterminal{UIdent}} {\nonterminal{ListPattern1}} \\ - & {\delimit} &{\nonterminal{Pattern1}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListDef}} & {\arrow} &{\emptyP} \\ - & {\delimit} &{\nonterminal{Def}} \\ - & {\delimit} &{\nonterminal{Def}} {\terminal{;}} {\nonterminal{ListDef}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListBranch}} & {\arrow} &{\emptyP} \\ - & {\delimit} &{\nonterminal{Branch}} \\ - & {\delimit} &{\nonterminal{Branch}} {\terminal{;}} {\nonterminal{ListBranch}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListInj}} & {\arrow} &{\emptyP} \\ - & {\delimit} &{\nonterminal{Inj}} \\ - & {\delimit} &{\nonterminal{Inj}} {\terminal{;}} {\nonterminal{ListInj}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListLIdent}} & {\arrow} &{\emptyP} \\ - & {\delimit} &{\nonterminal{LIdent}} {\nonterminal{ListLIdent}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListType}} & {\arrow} &{\emptyP} \\ - & {\delimit} &{\nonterminal{Type}} {\nonterminal{ListType}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListTVar}} & {\arrow} &{\emptyP} \\ - & {\delimit} &{\nonterminal{TVar}} {\nonterminal{ListTVar}} \\ -\end{tabular}\\ - -\begin{tabular}{lll} -{\nonterminal{ListPattern1}} & {\arrow} &{\nonterminal{Pattern1}} \\ - & {\delimit} &{\nonterminal{Pattern1}} {\nonterminal{ListPattern1}} \\ -\end{tabular}\\ - - - -\end{document} - diff --git a/Makefile b/Makefile index ccd1325..eef33fd 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY : sdist clean -language : src/Grammar/Test Grammar.tex +language : src/Grammar/Test Grammar.pdf cabal install --installdir=. --overwrite-policy=always src/Grammar/Test.hs src/Grammar/Lex.x src/Grammar/Par.y src/Grammar/Layout : Grammar.cf @@ -21,6 +21,10 @@ src/Grammar/Test : src/Grammar/Test.hs src/Grammar/Par.hs src/Grammar/Lex.hs src Grammar.tex : bnfc --latex Grammar.cf +Grammar.pdf : Grammar.tex + pdflatex Grammar.tex + rm Grammar.aux Grammar.dvi Grammar.fdb_latexmk Grammar.fls Grammar.log + clean : rm -r src/Grammar rm language