%% 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 LBNF} \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 LBNF} \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. String literals \nonterminal{String}\ have the form \terminal{"}$x$\terminal{"}, where $x$ is any sequence of any characters except \terminal{"}\ unless preceded by \verb6\6. 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{`''})*\) \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 LBNF are the following: \\ \begin{tabular}{lll} {\reserved{char}} & {\reserved{coercions}} & {\reserved{comment}} \\ {\reserved{digit}} & {\reserved{entrypoints}} & {\reserved{eps}} \\ {\reserved{internal}} & {\reserved{layout}} & {\reserved{letter}} \\ {\reserved{lower}} & {\reserved{nonempty}} & {\reserved{position}} \\ {\reserved{rules}} & {\reserved{separator}} & {\reserved{stop}} \\ {\reserved{terminator}} & {\reserved{token}} & {\reserved{toplevel}} \\ {\reserved{upper}} & & \\ \end{tabular} \\ The symbols used in LBNF are the following: \\ \begin{tabular}{lll} {\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 LBNF} 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{Cat}} & {\arrow} &{\nonterminal{Ident}} \\ & {\delimit} &{\terminal{[}} {\nonterminal{Cat}} {\terminal{]}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Def}} & {\arrow} &{\terminal{coercions}} {\nonterminal{Ident}} {\nonterminal{Integer}} \\ & {\delimit} &{\terminal{comment}} {\nonterminal{String}} \\ & {\delimit} &{\terminal{comment}} {\nonterminal{String}} {\nonterminal{String}} \\ & {\delimit} &{\terminal{entrypoints}} {\nonterminal{ListIdent}} \\ & {\delimit} &{\terminal{internal}} {\nonterminal{Label}} {\terminal{.}} {\nonterminal{Cat}} {\terminal{::{$=$}}} {\nonterminal{ListItem}} \\ & {\delimit} &{\terminal{layout}} {\nonterminal{ListString}} \\ & {\delimit} &{\terminal{layout}} {\terminal{stop}} {\nonterminal{ListString}} \\ & {\delimit} &{\terminal{layout}} {\terminal{toplevel}} \\ & {\delimit} &{\terminal{position}} {\terminal{token}} {\nonterminal{Ident}} {\nonterminal{Reg}} \\ & {\delimit} &{\nonterminal{Label}} {\terminal{.}} {\nonterminal{Cat}} {\terminal{::{$=$}}} {\nonterminal{ListItem}} \\ & {\delimit} &{\terminal{rules}} {\nonterminal{Ident}} {\terminal{::{$=$}}} {\nonterminal{ListRHS}} \\ & {\delimit} &{\terminal{separator}} {\nonterminal{MinimumSize}} {\nonterminal{Cat}} {\nonterminal{String}} \\ & {\delimit} &{\terminal{terminator}} {\nonterminal{MinimumSize}} {\nonterminal{Cat}} {\nonterminal{String}} \\ & {\delimit} &{\terminal{token}} {\nonterminal{Ident}} {\nonterminal{Reg}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Grammar}} & {\arrow} &{\nonterminal{ListDef}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{IntList}} & {\arrow} &{\terminal{[}} {\nonterminal{ListInteger}} {\terminal{]}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Item}} & {\arrow} &{\nonterminal{Cat}} \\ & {\delimit} &{\nonterminal{String}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Label}} & {\arrow} &{\nonterminal{LabelId}} {\nonterminal{LabelId}} \\ & {\delimit} &{\nonterminal{LabelId}} \\ & {\delimit} &{\nonterminal{LabelId}} {\nonterminal{ListProfItem}} \\ & {\delimit} &{\nonterminal{LabelId}} {\nonterminal{LabelId}} {\nonterminal{ListProfItem}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{LabelId}} & {\arrow} &{\nonterminal{Ident}} \\ & {\delimit} &{\terminal{(}} {\terminal{:}} {\terminal{)}} \\ & {\delimit} &{\terminal{[}} {\terminal{]}} \\ & {\delimit} &{\terminal{(}} {\terminal{:}} {\terminal{[}} {\terminal{]}} {\terminal{)}} \\ & {\delimit} &{\terminal{\_}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{MinimumSize}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\terminal{nonempty}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ProfItem}} & {\arrow} &{\terminal{(}} {\terminal{[}} {\nonterminal{ListIntList}} {\terminal{]}} {\terminal{,}} {\terminal{[}} {\nonterminal{ListInteger}} {\terminal{]}} {\terminal{)}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{RHS}} & {\arrow} &{\nonterminal{ListItem}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Reg}} & {\arrow} &{\nonterminal{Reg1}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListInteger}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Integer}} \\ & {\delimit} &{\nonterminal{Integer}} {\terminal{,}} {\nonterminal{ListInteger}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListString}} & {\arrow} &{\nonterminal{String}} \\ & {\delimit} &{\nonterminal{String}} {\terminal{,}} {\nonterminal{ListString}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListIdent}} & {\arrow} &{\nonterminal{Ident}} \\ & {\delimit} &{\nonterminal{Ident}} {\terminal{,}} {\nonterminal{ListIdent}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListDef}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Def}} {\terminal{;}} {\nonterminal{ListDef}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListIntList}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{IntList}} \\ & {\delimit} &{\nonterminal{IntList}} {\terminal{,}} {\nonterminal{ListIntList}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListItem}} & {\arrow} &{\emptyP} \\ & {\delimit} &{\nonterminal{Item}} {\nonterminal{ListItem}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListProfItem}} & {\arrow} &{\nonterminal{ProfItem}} \\ & {\delimit} &{\nonterminal{ProfItem}} {\nonterminal{ListProfItem}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{ListRHS}} & {\arrow} &{\nonterminal{RHS}} \\ & {\delimit} &{\nonterminal{RHS}} {\terminal{{$|$}}} {\nonterminal{ListRHS}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Reg1}} & {\arrow} &{\nonterminal{Reg1}} {\terminal{{$|$}}} {\nonterminal{Reg2}} \\ & {\delimit} &{\nonterminal{Reg2}} {\terminal{{$-$}}} {\nonterminal{Reg2}} \\ & {\delimit} &{\nonterminal{Reg2}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Reg2}} & {\arrow} &{\nonterminal{Reg2}} {\nonterminal{Reg3}} \\ & {\delimit} &{\nonterminal{Reg3}} \\ \end{tabular} \\ \begin{tabular}{lll} {\nonterminal{Reg3}} & {\arrow} &{\terminal{[}} {\nonterminal{String}} {\terminal{]}} \\ & {\delimit} &{\terminal{char}} \\ & {\delimit} &{\nonterminal{Char}} \\ & {\delimit} &{\terminal{digit}} \\ & {\delimit} &{\terminal{eps}} \\ & {\delimit} &{\terminal{letter}} \\ & {\delimit} &{\terminal{lower}} \\ & {\delimit} &{\nonterminal{Reg3}} {\terminal{?}} \\ & {\delimit} &{\nonterminal{Reg3}} {\terminal{{$+$}}} \\ & {\delimit} &{\terminal{\{}} {\nonterminal{String}} {\terminal{\}}} \\ & {\delimit} &{\nonterminal{Reg3}} {\terminal{*}} \\ & {\delimit} &{\terminal{upper}} \\ & {\delimit} &{\terminal{(}} {\nonterminal{Reg}} {\terminal{)}} \\ \end{tabular} \\ \end{document}