author | wenzelm |
Sun, 05 Feb 2012 21:00:38 +0100 | |
changeset 46292 | 4eb48958b50f |
parent 46291 | a1827b8b45ae |
permissions | -rw-r--r-- |
30184
37969710e61f
removed parts of the manual that are clearly obsolete, or covered by
wenzelm
parents:
20093
diff
changeset
|
1 |
|
320 | 2 |
\chapter{Defining Logics} \label{Defining-Logics} |
3 |
||
4 |
\section{Mixfix declarations} \label{sec:mixfix} |
|
5 |
||
6 |
\subsection{Example: arithmetic expressions} |
|
7 |
\index{examples!of mixfix declarations} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
711
diff
changeset
|
8 |
This theory specification contains a {\tt syntax} section with mixfix |
320 | 9 |
declarations encoding the priority grammar from |
10 |
\S\ref{sec:priority_grammars}: |
|
11 |
\begin{ttbox} |
|
3108 | 12 |
ExpSyntax = Pure + |
320 | 13 |
types |
14 |
exp |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
711
diff
changeset
|
15 |
syntax |
1387 | 16 |
"0" :: exp ("0" 9) |
17 |
"+" :: [exp, exp] => exp ("_ + _" [0, 1] 0) |
|
18 |
"*" :: [exp, exp] => exp ("_ * _" [3, 2] 2) |
|
19 |
"-" :: exp => exp ("- _" [3] 3) |
|
320 | 20 |
end |
21 |
\end{ttbox} |
|
864
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
711
diff
changeset
|
22 |
Executing {\tt Syntax.print_gram} reveals the productions derived from the |
d63b111b917a
quite a lot of minor and major revisions (inspecting theories, read_axm,
wenzelm
parents:
711
diff
changeset
|
23 |
above mixfix declarations (lots of additional information deleted): |
320 | 24 |
\begin{ttbox} |
3108 | 25 |
Syntax.print_gram (syn_of ExpSyntax.thy); |
320 | 26 |
{\out exp = "0" => "0" (9)} |
27 |
{\out exp = exp[0] "+" exp[1] => "+" (0)} |
|
28 |
{\out exp = exp[3] "*" exp[2] => "*" (2)} |
|
29 |
{\out exp = "-" exp[3] => "-" (3)} |
|
30 |
\end{ttbox} |
|
31 |
||
5371 | 32 |
%%% Local Variables: |
33 |
%%% mode: latex |
|
34 |
%%% TeX-master: "ref" |
|
35 |
%%% End: |