Hallo,
ahhh, da wäre ich nicht drauf gekommen. Ok, und das mit dem Matrixnamen macht Sinn.
Also ich habe es jetzt fast so, wie ich es haben möchte:
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing,matrix}
\colorlet{bgcolor}{white} % Farbe für background
\colorlet{ccolor}{darkgray} % Farbe für comments
\colorlet{kwcolor}{red} % Farbe für keywords
\colorlet{scolor}{green} % Farbe für strings
\lstset{
language=Haskell,
basicstyle=\ttfamily,
numbers=left,
showstringspaces=false,
commentstyle=\itshape\color{ccolor},
keywordstyle=\bfseries\color{kwcolor},
stringstyle=\color{scolor},
backgroundcolor=\color{bgcolor},
breaklines=true,
breakautoindent=true,
columns=flexible,
frame=single,
captionpos=b,
xleftmargin=3em,
xrightmargin=1em,
aboveskip=10pt
}
\begin{document}
\begin{lstlisting}[title={Program P},label=P,mathescape=true]
f(a,b) = if b = 1 then a else 1:g(a,b-1,a)
g(c,d,e) = if d = 1 then e$\cdot$c else 2:g(c,d-1,e$\cdot$c)
\end{lstlisting}
\begin{tikzpicture}
\matrix (lstline) [%
matrix of nodes,
nodes={anchor=base,font=\ttfamily}
] {
f(a,b) & = & |[kwcolor]|if & b & = & 1 & |[kwcolor]|then & a & |[kwcolor]|else & 1:g(a,b-1,a) \\
};
\draw[decorate,decoration=brace] ($(lstline-1-1.south east)+(-0.9em,0.5ex)$) -- ($(lstline-1-1.south west)+(1.4em,0.5ex)$) node[below,pos=0.5,font=\scriptsize] {parameters};
\draw[decorate,decoration=brace] (lstline-1-10.south east) -- (lstline-1-3.south west) node[below,pos=0.5,font=\scriptsize] {function body};
\draw[decorate,decoration=brace] (lstline-1-10.north west) -- (lstline-1-10.north east) node[above,pos=0.5,font=\scriptsize] {a call};
\end{tikzpicture}
Aber irgendwie ist die "function body" Schleife schief. Ich habe das Konzept auch noch nicht recht begriffen....
\draw[decorate,decoration=brace] (lstline-1-10.south east) -- (lstline-1-3.south west) node[below,pos=0.5,font=\scriptsize] {function body};
Gut, ich sage also draw, dass er ne Schleife machen soll. Dann gebe ich den ersten Knoten an, dann den zweiten, also von wo bis wo die Schleife sein soll. Mit south est etc spezifiziere ich den genauen anchor. Was genau sagt das node[...]? Warum ist die Schleife "falsch" rum, wenn ich zuerst den anderen Knoten als Ausgangspunkt wähle?
Gruß
Guenter