summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/formal-grammar
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-11-13 21:13:55 +0000
committerKarl Berry <karl@freefriends.org>2021-11-13 21:13:55 +0000
commit09fb10e18bc08cea7aa46f661f3643b4bc6cde4c (patch)
treef0eb9f1d070046e2da06943c0606add5915e9121 /Master/texmf-dist/tex/latex/formal-grammar
parent640afb3c3409328eb49d71e28d5d9511ff7de3b1 (diff)
formal-grammar (12nov21)
git-svn-id: svn://tug.org/texlive/trunk@61046 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/formal-grammar')
-rw-r--r--Master/texmf-dist/tex/latex/formal-grammar/formal-grammar.sty101
1 files changed, 101 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/formal-grammar/formal-grammar.sty b/Master/texmf-dist/tex/latex/formal-grammar/formal-grammar.sty
new file mode 100644
index 00000000000..90eaa407da6
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/formal-grammar/formal-grammar.sty
@@ -0,0 +1,101 @@
+%%
+%% This is file `formal-grammar.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% formal-grammar.dtx (with options: `package')
+%% This is a generated file.
+%% Copyright (C) 2021 by Martin Vassor
+%%
+%% This file may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either
+%% version 1.3 of this license or (at your option) any later
+%% version. The latest version of this license is in:
+%%
+%% http://www.latex-project.org/lppl.txt
+%%
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2005/12/01 or later.
+%%
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{formal-grammar}[2021/11/10 v1.0 A package to typeset formal grammars]
+\RequirePackage{xparse}
+\RequirePackage{float}
+\RequirePackage{xcolor}
+\RequirePackage{colortbl}
+\RequirePackage{array}
+\definecolor{LightCyan}{rgb}{0.8,1,1}
+%% \begin{abstract}
+%% The \textsf{formal-grammar} package provides commands to typeset formal grammars.
+%% \end{abstract}
+\newfloat{floatgrammar}{t b h p}{.gram}
+\floatname{floatgrammar}{Grammar}
+%% Taken from https://tex.stackexchange.com/a/26364/107341
+\newcommand*{\@rowstyle}{}
+
+\newcommand*{\rowstyle}[1]{% sets the style of the next row
+ \gdef\@rowstyle{#1}%
+ \@rowstyle\ignorespaces%
+}
+\newcolumntype{=}{% resets the row style
+ >{\gdef\@rowstyle{}}%
+}
+
+\newcolumntype{+}{% adds the current row style to the next column
+ >{\@rowstyle}%
+}
+%% End of stackexchange
+\ExplSyntaxOn
+%% 1st argument: caption (makes it float)
+%% 2nd argument: positionning option (`p` by default)
+%% 3rd argument: label
+\NewDocumentEnvironment{grammar} {o o o}
+{
+\IfNoValueTF{#1} {
+}{
+\IfNoValueTF{#2}{
+\begin{floatgrammar}[p]
+} {
+\begin{floatgrammar}[#2]
+}
+\centering
+}
+
+\begin{tabular}{=l +r +l +l}
+}{
+\end{tabular}
+
+\IfNoValueTF{#1} {
+\linebreak
+} {
+\caption{#1}
+\IfNoValueTF{#3}{
+} {
+\label{#3}
+}
+\end{floatgrammar}
+}
+}
+\ExplSyntaxOff
+
+\newcommand{\firstcase}[3]{\(\mathcal{#1}\) & \(::=\) & \(#2\) & {\itshape \color{gray!90!black} #3}\\}
+\newcommand{\firstcasesubtil}[3]{#1 & \(::=\) & \(#2\) & {\itshape \color{gray!90!black} #3}\\}
+
+\newcommand{\otherform}[2]{& \(|\) & \(#1\) & {\itshape \color{gray!90!black} #2}\\}
+
+\newcommand{\nonterm}[1]{\mathcal{#1}}
+
+\newcommand{\nontermsubtil}[1]{#1}
+
+\newcommand{\gralt}[0]{\quad |\quad }
+
+\newcommand{\highlight}[0]{\rowcolor{LightCyan}}
+
+\newcommand{\lochighlight}[1]{{\color{red} #1}}
+
+\newcommand{\downplay}[0]{\rowstyle{\color{white!80!black}}}
+\endinput
+%%
+%% End of file `formal-grammar.sty'.