[Tex/LaTex] tikz: connecting to a rectangle split shape

tikz-pgf

I want to draw a simple diagram using tikz to show the structure of a compiler front end.

The compiler is being represented with a node using rectangle split shape containing three parts. The input and output are being represented by rectangles node and should connect to the left of the first and to the right of the last parts of the split shape, respectively.

I have written the document below, but it is not working.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart,positioning}

\begin{document}

\begin{tikzpicture}[thick, data/.style={rectangle,fill=red!12}]
  \node[rectangle split,rectangle split parts=3,draw,anchor=center] (compiler) {
    lexical analysis\nodepart{two}
    syntatic analysis\nodepart{three}
    semantic analysis
  };

  \node[data] (src) [left=of compiler.text,align=center] {source code};
  \node[data] (obj) [right=of compiler.three,align=center] {intermediate code};

  \draw [->] (src.east) -- (compiler.text west);
  \draw [->] (compiler.three east) -- (obj.west);
\end{tikzpicture}

\end{document}

compiler front end

How should it be modified to work as expected?

Best Answer

Simply changing from left=of compiler.text and right=of compiler.three to left=of compiler.text west and right=of compiler.three east for the src and obj nodes improves the output.

enter image description here

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.multipart,positioning}

\begin{document}

\begin{tikzpicture}[thick, data/.style={rectangle,fill=red!12}]
  \node[rectangle split,rectangle split parts=3,draw,anchor=center] (compiler) {
    lexical analysis\nodepart{two}
    syntatic analysis\nodepart{three}
    semantic analysis
  };

  \node[data] (src) [left=of compiler.text west,align=center] {source code};
  \node[data] (obj) [right=of compiler.three east,align=center] {intermediate code};

  \draw [->] (src.east) -- (compiler.text west);
  \draw [->] (compiler.three east) -- (obj.west);
\end{tikzpicture}

\end{document}