%% File generated by the BNF Converter. \batchmode \documentclass[a4paper,11pt]{article} \usepackage[T1]{fontenc} \usepackage[utf8x]{inputenc} \setlength{\parindent}{0mm} \setlength{\parskip}{1mm} \title{The Language Prolog} \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}. \section*{The lexical structure of Prolog} Ident literals are recognized by the regular expression \(({\nonterminal{lower}} \mid {\nonterminal{upper}}) ({\nonterminal{upper}} \mid {\nonterminal{lower}} \mid {\nonterminal{digit}} \mid \mbox{`\_'} \mid \mbox{`''})*\) LIdent literals are recognized by the regular expression \(({\nonterminal{lower}}) ({\nonterminal{lower}} \mid {\nonterminal{upper}} \mid {\nonterminal{digit}} \mid \mbox{`\_'})*\) UIdent literals are recognized by the regular expression \(({\nonterminal{upper}}) ({\nonterminal{lower}} \mid {\nonterminal{upper}} \mid {\nonterminal{digit}} \mid \mbox{`\_'})*\) Wild literals are recognized by the regular expression \((\mbox{`\_'}) ({\nonterminal{anychar}})*\) \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. There are no reserved words in Prolog. The symbols used in Prolog are the following: \\ \begin{tabular}{lll} {\symb{'}} & {\symb{(}} & {\symb{)}} \\ {\symb{,}} & {\symb{.}} & {\symb{:{$-$}}} \\ {\symb{[}} & {\symb{]}} & {\symb{{$|$}}} \\ \end{tabular} \\ \subsection*{Comments} There are no single-line comments in the grammar. There are no multiple-line comments in the grammar. \section*{The syntactic structure of Prolog} 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{Atom}} & {\arrow} &{\nonterminal{LIdent}} \\ & {\delimit} &{\terminal{'}} {\nonterminal{Ident}} {\terminal{'}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Clause}} & {\arrow} &{\terminal{:{$-$}}} {\nonterminal{ListPredicate}} \\ & {\delimit} &{\nonterminal{Predicate}} \\ & {\delimit} &{\nonterminal{Predicate}} {\terminal{:{$-$}}} {\nonterminal{ListPredicate}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Database}} & {\arrow} &{\nonterminal{ListClause}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{List}} & {\arrow} &{\terminal{[}} {\nonterminal{ListTerm}} {\terminal{{$|$}}} {\nonterminal{List}} {\terminal{]}} \\ & {\delimit} &{\terminal{[}} {\nonterminal{ListTerm}} {\terminal{{$|$}}} {\nonterminal{Var}} {\terminal{]}} \\ & {\delimit} &{\terminal{[}} {\terminal{]}} \\ & {\delimit} &{\terminal{[}} {\nonterminal{ListTerm}} {\terminal{]}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Predicate}} & {\arrow} &{\nonterminal{Atom}} \\ & {\delimit} &{\nonterminal{Atom}} {\terminal{(}} {\nonterminal{ListTerm}} {\terminal{)}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Term}} & {\arrow} &{\nonterminal{Atom}} {\terminal{(}} {\nonterminal{ListTerm}} {\terminal{)}} \\ & {\delimit} &{\nonterminal{Atom}} \\ & {\delimit} &{\nonterminal{List}} \\ & {\delimit} &{\nonterminal{Var}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Var}} & {\arrow} &{\nonterminal{Wild}} \\ & {\delimit} &{\nonterminal{UIdent}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListClause}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Clause}} {\terminal{.}} {\nonterminal{ListClause}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListPredicate}} & {\arrow} &{\nonterminal{Predicate}} \\ & {\delimit} &{\nonterminal{Predicate}} {\terminal{,}} {\nonterminal{ListPredicate}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListTerm}} & {\arrow} &{\nonterminal{Term}} \\ & {\delimit} &{\nonterminal{Term}} {\terminal{,}} {\nonterminal{ListTerm}} \\ \end{tabular} \\ \end{document}