% macros.sty
% (re)define some commands:
%
\usepackage{ifthen}

% tuples
\newcommand{\tup}[1]{\langle #1\rangle}
% new
\newcommand{\func}[1]{\text{\textnormal{#1}}}
\newcommand{\N}[1]{<~\negthickspace\negthickspace\mathit{#1}\negthickspace\negthickspace~>}
\newcommand{\Np}[1]{<~\negthickspace\negthickspace\mathit{#1}\!\negmedspace\negthickspace~>}
\newcommand{\rel}[1]{\text{\textbf{~#1~}}}
\newcommand{\rela}[1]{\text{\textbf{~#1}}^\ast}
\newcommand{\relp}[1]{\text{\textbf{~#1}}^+}
\newcommand{\pfx}[1]{1\negmedspace:\negmedspace#1}
\newcommand{\vd}[1]{\vdash\negthickspace\negthickspace\negthickspace\protect\raisebox{-0.3em}{\mbox{\tiny{#1}}}}
\newcommand{\shift}{\vd{shift}}
\newcommand{\red}[1]{\vd{$#1$}}
\newcommand{\rewrt}[1]{\models\negthickspace\negthickspace\negthickspace\protect\raisebox{-0.3em}{\mbox{\tiny{#1}}}}
\newcommand{\rewr}[1]{\rewrt{$#1$}}
\newcommand{\st}[1]{\llbracket #1\rrbracket}
\newcommand{\todo}{{\color[rgb]{1,0,0} \textbf{TODO}}}
% symbols
\renewcommand{\a}{\alpha}
\renewcommand{\b}{\beta}
%\renewcommand{\c}{\gamma}
\renewcommand{\d}{\delta}
\renewcommand{\j}{\xi}
\renewcommand{\k}{\kappa}
\renewcommand{\l}{\lambda}
\renewcommand{\r}{\rho}
\renewcommand{\t}{\tau}
\newcommand{\e}{\varepsilon}
\newcommand{\f}{\varphi}
\newcommand{\g}{\gamma}
\newcommand{\m}{\mu}
\newcommand{\s}{\sigma}
\newcommand{\x}{\chi}
\newcommand{\w}{\omega}
\newcommand{\z}{\zeta}
%\renewcommand{\i}{\iota}
\newcommand{\n}{\nu}

\newcommand{\T}{{\cal T}}
\newcommand{\K}{{\cal K}}
\newcommand{\C}[1]{\mathcal{C}_{\text{#1}}}
% construction relation
\newcommand{\ir}[1][]{\mbox{$\stackrel{\mbox{\scriptsize{$#1$}}}{\rightharpoondown\negthickspace\negthickspace\negthickspace\rightharpoondown\negthickspace\negthickspace\negthickspace\rightharpoondown}$}}
\newcommand{\irn}[2][]{\mbox{$\ir[#1]\protect\raisebox{0.3em}{\mbox{\tiny{$#2$}}}$}}
\newcommand{\ira}[1][]{\mbox{$\irn[#1]{\ast}$}}
\newcommand{\irp}[1][]{\mbox{$\irn[#1]{+}$}}
% parent relation
\newcommand{\pa}[2][]{\mbox{$\stackrel{\mbox{\scriptsize{$#1$}}}{\leadsto}_{\mbox{\negthinspace\tiny{#2}\thinspace}}$}}% ^i^>
\newcommand{\pan}[3][]{\mbox{$\pa[#1]{#2}\protect\raisebox{0.3em}{\mbox{\tiny{$#3$}}}$}}
\newcommand{\paa}[2][]{\mbox{$\pan[#1]{#2}{\ast}$}}
\newcommand{\pap}[2][]{\mbox{$\pan[#1]{#2}{+}$}}
% lookaheads
\newcommand{\Lak}{\func{La}_k}
\newcommand{\RLak}{\func{La}_k^{\rm lm}}
% valid item sets
\newcommand{\Val}{\func{Valid}}
% language
\renewcommand{\L}{{\cal L}}
% grammar
\newcommand{\bof}{\$}                  % |-
\newcommand{\eof}{\$}                  % -|
\newcommand{\G}{{\cal G}}                  % grammar
\newcommand{\Va}{V^{\ast}}                 % V*
\newcommand{\Vp}{V^{\scriptscriptstyle+}}  % V+
\newcommand{\Ta}{T^{\ast}}                 % T*
\newcommand{\Tz}{T^{\scriptscriptstyle 0}} % T+
\newcommand{\Tp}{T^{\scriptscriptstyle+}}  % T+
% productions
\renewcommand{\P}{\mbox{$\rightarrow$}} % -->
\newcommand{\pP}[1]{\mbox{$\stackrel{#1}{\longrightarrow}$}} % --i-->

% derivations
\newcommand{\Rm} {\rm rm}                          % rm for rightmost
\newcommand{\Lm} {\rm lm}                          % lm for leftmost
\newcommand{\D}  {\mbox{$\Rightarrow$}}            % derivation
\newcommand{\Dp} {\mbox{$\D^{\scriptscriptstyle+}$}}  % D+
\newcommand{\Da} {\mbox{$\D^{\ast}$}}               % D*
\newcommand{\Do}[1][\Pi]{\raisebox{-.9ex}{\mbox{$\stackrel{\D}{\scriptscriptstyle{\rm #1}}$}}}
\newcommand{\Di}[1][\Pi]{\mbox{$\stackrel{\scriptstyle{#1}}{\D}$}}
\newcommand{\Dr} {\Do[rm]}
\newcommand{\Dl} {\Do[lm]}
\newcommand{\Drp}{\mbox{$\Dr^{\scriptscriptstyle+}$}} % Drm+
\newcommand{\Dra}{\mbox{$\Dr^{\ast}$}}              % Drm*
\newcommand{\Doa}{\mbox{$\Do^{\ast}$}}              % Do*
\newcommand{\Dop}{\mbox{$\Do^{\scriptscriptstyle+}$}} % Do+
\newcommand{\Dla}{\mbox{$\Dl^{\ast}$}}              % Dlm*
% dot
\newcommand{\p}{\protect\raisebox{-0.5ex}{\mbox{\huge$\cdot$}}} % ·
% emphasize keywords
\newcommand{\define}{\emph}
% theorems
%\newtheorem{theorem}{Theorem}%[chapter]
%\newtheorem{lemma}{Lemma}%{Lemma}
%% \newenvironment{lemma}
%%   {\addtocounter{theorem}{1}\begin{lemm}}
%%   {\end{lemm}\addtocounter{theorem}{-1}}
%\newtheorem{definition}{Definition}%[theorem]{Definition}
%% %\renewcommand{\thedefinition}{}
%\newtheorem{corollary}{Corollary}%[theorem]%{Corollary}
%\newenvironment{proof}{\textit{Proof.}}{\hfill$\Box$\\}
% grammars
\newcounter{grammar}
\newcommand{\gr}[1]{% New grammar name; use: \gr{label}
\refstepcounter{grammar}\label{gram:#1}\text{$\G_\thegrammar$}%
}
\newcommand{\grf}[1]{% Refers to a grammar name; use: \grf{label}
  \text{$\G_{\ref{gram:#1}}$}%
}
\newcommand{\gor}{\negthinspace\mid\negthinspace} % BNF alternation
\newcommand{\gdf}[2][]{% Defines a new grammar; use: \gdf[label]{grammar rules}
  \ifthenelse{\equal{#1}{}}%
    {%
      \[#2\]%
    }%
    {%
      \[#2\refstepcounter{grammar}\label{gram:#1}\eqno{(\G_\thegrammar})\]%
    }%
}
%
% correct accent for Karel Culik(!)
\newcommand{\Culik}{$\check{\mbox{C}}$ulik\xspace}
% acronyms
\newcommand{\acr}[1]{(#1)\xspace}
% non break dash
\newcommand{\nbd}{\nobreakdash}
\newcommand{\ed}{$\e$\nbd}  % 'epsilon-'stuff,
                            % weird error when put in \paragraph
%
% states
%% \newcommand{\st}[1]{% whoosh! had a hard time doing this one
%%   \mbox{%
%%     \normalsize{$%
%%       \bigcirc%
%%       \ifthenelse{#1 > 9}%
%%         {%
%%           \negthickspace\negthickspace\negthickspace%
%%           \protect\raisebox{0.2ex}{\mbox{\tiny{#1}}}%
%%           \thinspace%
%%         }%
%%         {%
%%           \negthickspace\negmedspace\negthinspace%
%%           \protect\raisebox{0.2ex}{\mbox{\tiny{#1}}}%
%%           \thickspace%        
%%         }%
%%     $}%
%%   }%
%% }
% table with comments
%% \newlength{\myhspace}
%% \setlength{\myhspace}{0em}
%% \newlength{\myminipagewidth}
%% \setlength{\myminipagewidth}{235pt}
%% \newcommand{\tcomment}[1]{%
%%   \multicolumn{3}{l}{%
%%     \hspace{-5pt}%
%%     \begin{minipage}[t]{235pt}%
%%         {\footnotesize%
%%           #1\vspace{0.4em}
%%           }%
%%     \end{minipage}%
%%   }%
%% }
%% % copyright space (for compatibility with ACM styles)
%% \providecommand{\copyrightspace}{}
%% % figure and table space
%% \newlength{\myfigbsp}
%% \setlength{\myfigbsp}{-2em} % bottom space
%% \newlength{\myfigtsp}
%% \setlength{\myfigtsp}{-1.5em} % top space
%% \newlength{\myfigcsp}
%% \setlength{\myfigcsp}{-1.5em} % caption space
%% \newlength{\mytabbsp}
%% \setlength{\mytabbsp}{-2em} % bottom space

%% % lists
%% \newcommand{\condlabel}[1]{(#1)}
%% \newlength{\condlength}
%% \newenvironment{conditions}[1]%
%%   { \begin{list}{}%
%%       { \renewcommand{\makelabel}[1]{\condlabel{##1}\hfil}%
%%         \settowidth{\condlength}{\condlabel{#1}}%
%%         \setlength{\labelwidth}{\condlength}%
%%         \setlength{\labelsep}{1em}%
%%         \setlength{\itemsep}{0.5em}%
%%         \setlength{\leftmargin}{\labelwidth}%
%%         \addtolength{\leftmargin}{\labelsep}%
%%         \renewcommand{\theenumi}{\alph{enumi}}%
%%         \renewenvironment{enumerate}%
%%           { \begin{list}{\labelenumi}%
%%               { \usecounter{enumi}%
%%                 \setlength{\itemsep}{0pt}%
%%                 \addtolength{\leftmargin}{-\condlength}}}%
%%           {\end{list}}%
%%         \renewenvironment{itemize}%
%%           { \begin{list}{}%
%%               { \setlength{\itemindent}{-1.7em}%
%%                 \setlength{\itemsep}{0pt}}}%
%%           {\end{list}}%
%%       }%
%%   }%
%%   {\end{list}}
