Skip to content

Instantly share code, notes, and snippets.

@SammysHP
Created November 7, 2014 21:28
Show Gist options
  • Save SammysHP/59fb984814d5c7ef73fb to your computer and use it in GitHub Desktop.
Save SammysHP/59fb984814d5c7ef73fb to your computer and use it in GitHub Desktop.
TikZ Kellerautomat, Beispiel: http://i.imgur.com/UfTfXl9.png
\begin{tikzpicture}
\begin{scope}[start chain, node distance=-0.15mm]
\node [tmtapehend] (inputbegin) {};
\node [tmtape] {$a_1$};
\node [tmtape] {$a_2$};
\node [tmtape, minimum width=2\tmtapesize] {$\ldots$};
\node [tmtape] (inputcursor) {};
\node [tmtape, minimum width=2\tmtapesize] {$\ldots$};
\node [tmtapehend] (inputend) {};
\end{scope}
\begin{scope}[start chain=going below, node distance=-0.15mm]
\node [tmtapevend, below=1cm of inputend] {};
\node [tmtape] (stackcursor) {$D$};
\node [tmtape] {$C$};
\node [tmtape] {$B$};
\node [tmtape] {$A$};
\node [tmtape] (stackend) {$\#$};
\end{scope}
\node [tmtapecursor] (inputcursor) at (inputcursor) {};
\node [tmtapecursor] (stackcursor) at (stackcursor) {};
\node [draw, align=center, inner sep=3mm] (control) [left=2cm of stackcursor] {endliche Kontrolle\\(Zustand)};
\node [align=center, font=\scriptsize, inner sep=0pt, above=2mm of inputcursor] {Lesekkopf, bewegt\\sich nach rechts};
\node [align=left, font=\scriptsize, inner sep=0pt, right=2mm of stackcursor] {Lesekkopf, steht immer auf\\dem obersten Kellersymbol};
\node [inner sep=0pt, above right=2mm and -\tmtapesize of inputbegin] {Eingabeband};
\node [inner sep=0pt, below=3mm of stackend] {Keller};
\begin{scope}[->, >=stealth', shorten >=1pt, auto]
\draw (control) edge (stackcursor);
\draw (control.north) -- ++(0,0.75) -| (inputcursor);
\end{scope}
\end{tikzpicture}
\newlength{\tmtapesize}
\setlength{\tmtapesize}{9mm}
\tikzset{tmtape/.style={
draw,
minimum size=\tmtapesize,
inner sep=0,
text height=1.8ex,
text depth=0.25ex,
on chain
}
}
\tikzset{tmtapehend/.style={
minimum size=\tmtapesize,
line width=0pt,
on chain,
append after command={
(\tikzlastnode.north west) edge (\tikzlastnode.north east)
(\tikzlastnode.south west) edge (\tikzlastnode.south east)
}
}
}
\tikzset{tmtapevend/.style={
minimum size=\tmtapesize,
line width=0pt,
on chain,
append after command={
(\tikzlastnode.north west) edge (\tikzlastnode.south west)
(\tikzlastnode.north east) edge (\tikzlastnode.south east)
}
}
}
\tikzset{tmtapecursor/.style={
minimum size=\dimexpr\tmtapesize+2mm,
draw=maincolor,
rounded corners=1mm,
fill=maincolor,
fill opacity=0.1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment