mirror of
https://github.com/thufschmitt/tix-papers.git
synced 2024-09-11 13:00:34 +03:00
grammar: visually separate syntax and meta-syntax
This commit is contained in:
parent
8085fb5d79
commit
5d85837489
@ -9,6 +9,19 @@
|
||||
\date{}
|
||||
|
||||
\renewcommand{\grammarlabel}[2]{#1 #2}
|
||||
\usepackage{xspace}
|
||||
|
||||
\newcommand{\stx}[1]{\texttt{#1}} % For concrete syntax
|
||||
\newcommand{\meta}[1]{\emph{#1}} % For concrete syntax
|
||||
|
||||
\def\e/{\meta{e}}
|
||||
\def\a/{\meta{a}}
|
||||
\def\b/{\meta{b}}
|
||||
\def\c/{\meta{c}}
|
||||
\def\p/{\meta{p}}
|
||||
\def\q/{\meta{q}}
|
||||
\def\f/{\meta{f}}
|
||||
\def\x/{\meta{x}}
|
||||
|
||||
\begin{document}
|
||||
|
||||
@ -16,35 +29,35 @@
|
||||
|
||||
\begin{grammar}
|
||||
<e> ::=
|
||||
x | c
|
||||
\alt e.a | e.a or e
|
||||
\alt p:e | e e
|
||||
\alt [ e ... e ] | \{ e = e; ...; e = e; \}
|
||||
\alt with e; e
|
||||
\alt if e then e else e
|
||||
\alt let x = e; ...; x = e; in e
|
||||
\textcolor{blue}{\alt e :: e | nil}
|
||||
\alt attrNames e | listToAttrs e
|
||||
\alt addAttr e e e | removeAttr e e
|
||||
\x/ | \c/
|
||||
\alt \e/\stx{.}\a/ | \e/\stx{.}\a/ \stx{or} \e/
|
||||
\alt \p/\stx{:}\e/ | \e/ \e/
|
||||
\alt \stx{[} \e/ \ldots{} \e/ \stx{]} | \stx{\{} \e/ \stx{=} \e/\stx{;} ...\stx{;} \e/ \stx{=} \e/\stx{; \}}
|
||||
\alt \stx{with} \e/\stx{;} \e/
|
||||
\alt \stx{if} \e/ \stx{then} \e/ \stx{else} \e/
|
||||
\alt \stx{let} \x/ \stx{=} \e/\stx{; \ldots{};} \x/ \stx{=} \e/\stx{; in} \e/
|
||||
\textcolor{blue}{\alt \e/ \stx{::} \e/ | \stx{nil}}
|
||||
\alt \stx{attrNames} \e/ | \stx{listToAttrs} \e/
|
||||
\alt \stx{addAttr} \e/ \e/ \e/ | \stx{removeAttr} \e/ \e/
|
||||
% Not as-if in nix, but simpler than the actual builtins ("//" or
|
||||
% removeAttrs), and yet sufficient thanks to attrNames and listToAttrs
|
||||
\alt deepSeq e e
|
||||
\alt functionArgs e
|
||||
\alt \stx{deepSeq} \e/ \e/
|
||||
\alt \stx{functionArgs} \e/
|
||||
% Maybe this can be typed as a function, but it is rather unlikely
|
||||
|
||||
<a> ::= b. ... .b
|
||||
<a> ::= \b/\stx{.} \ldots{} \stx{.}\b/
|
||||
|
||||
<b> ::= \$\{e\} | l
|
||||
<b> ::= \stx{\$\{}\e/\stx{\}} | \meta{l}
|
||||
|
||||
<c> ::= s | i | ...
|
||||
\alt typeOf
|
||||
\alt ...
|
||||
<c> ::= \meta{s} | \meta{i} | \ldots{}
|
||||
\alt \stx{typeOf}
|
||||
\alt \ldots{}
|
||||
|
||||
<p> ::= q | q@x | x
|
||||
<p> ::= \q/ | \q/\stx{@}\x/ | \x/
|
||||
|
||||
<q> ::= \{ f, ..., f \} | \{ f, ..., f, … \}
|
||||
<q> ::= \stx{\{} \f/\stx{, \ldots{},} \f/ \stx{\}} | \stx{\{} \f/\stx{, \ldots{},} \f/ \stx{, ...\}}
|
||||
|
||||
<f> ::= x | x ? e
|
||||
<f> ::= \x/ | \x/ \stx{?} \e/
|
||||
|
||||
\end{grammar}
|
||||
\end{document}
|
||||
|
Loading…
Reference in New Issue
Block a user