%
% Mite commands package
%
% Reuben Thomas   2/9/96-24/10/00, 2/6/06
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mite}

% Standard packages used
\RequirePackage{longtable}
\RequirePackage{booktabs}
\RequirePackage{calc}
\RequirePackage{amsmath}
\RequirePackage{xspace}
\RequirePackage{newlfont}
\RequirePackage{lips}
\RequirePackage[normalem]{ulem}


% My packages used
\RequirePackage{reggram}
\RequirePackage{codex}


% Alter some default parameters for general typesetting
\frenchspacing
\setcounter{secnumdepth}{4}


% New commands

\providecommand{\cont}{\noindent} % Abbreviation for \noindent
\newcommand{\tab}{\hspace*{8mm}} % for continuation lines that overrun
\newcommand{\vlips}% vertical ellipsis for code examples
    {\hspace*{2ex}%
    \vbox{\baselineskip4pt\lineskiplimit0pt\kern3pt\hbox{.}\hbox{.}\hbox{.}}}
\newcommand{\inst}[1]{\fbox{\rule[-1.5pt]{0pt}{1.5pt}#1}}
% preserve backslash (from LaTeX Companion)
\newcommand{\PBS}[1]{\let\temp=\\#1\let\\=\temp}

% Font names
\providecommand{\conc}[1]{\texttt{#1}} % registers, terminals in BNF &c.
\providecommand{\abs}[1]{\textsf{#1}} % instruction names in semantics
\newcommand{\define}[1]{\textbf{#1}} % words being defined
\newcommand{\bitname}[1]{\textsf{#1}} % named bitfield
\newcommand{\bitnum}[1]{\textit{#1}} % number bitfield

% Width of a digit
\newsavebox{\digitwidthbox}
\newlength{\digitwidth}
\newcommand{\setdigitwidth}%
    {\sbox{\digitwidthbox}{0}\setlength{\digitwidth}{\wd\digitwidthbox}}

% Logic
\newcommand{\NOT}[1]{\ensuremath{\bar #1}}
\newcommand{\AND}{\ \& \ }
\newcommand{\OR}{\ | \ }

% Abbreviations for \bits with particular fonts
\newcommand{\bitsl}[2]{\bits[r]{#1}{#1}{\conc{#2}}} % Literal
\newcommand{\bitsn}[2]{\bits[r]{#1}{#1}{\bitname{#2}}} % Named

% Environment for abstract syntax definitions (sans-serif LHS, math RHS)
% raw non--page-breaking version
\newenvironment{bnfaraw}[1][MMMMMMMMMM]%
    {\begin{bnf}[#1]{\textsf}{rm}}{\end{bnf}}
% raw page-breaking version
\newenvironment{bnfaraw*}[1][MMMMMMMMMM]%
    {\begin{bnf*}[#1]{\textsf}{rm}}{\end{bnf*}}
% spaced non--page-breaking version
\newenvironment{bnfa}[1][MMMMMMMMMM]%
    {\begin{flushleft}\begin{bnfaraw}[#1]}{\end{bnfaraw}\end{flushleft}}
% spaced page-breaking version
\newenvironment{bnfa*}[1][MMMMMMMMMM]%
    {\begin{flushleft}\begin{bnfaraw*}[#1]}{\end{bnfaraw*}\end{flushleft}}

% Underline for side-conditions in semantics
\newcommand{\sidecond}[1]%
    {\raisebox{-\depth}{%
        \uline{\raisebox{\depth}{#1}}}
    \\\smallskip}
