1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| \usetikzlibrary{positioning, arrows.meta, calc} \tikzset{ arrow1/.style = { draw = purple, thick, -{Latex[length = 4mm, width = 1.5mm]}, } } \tikzset{ nonterminal/.style = { rectangle, align = center, minimum size = 6mm, very thick, draw = red!50!black!50, top color = white, bottom color = red!50!black!20, } } \tikzset{ terminal/.style = { rectangle, align = center, minimum size = 6mm, rounded corners = 3mm, very thick, draw = black!50, top color = white, bottom color = black!20, } } \hspace{-3cm}{ \begin{minipage}{15.4cm} \begin{tikzpicture}[node distance = 0.7cm] \node[terminal](function){FUNCTION}; \node[nonterminal, right = of function](name1){Function name}; \node[terminal, right = of name1](left){(}; \node[terminal, right = of left](var){VAR}; \node[nonterminal, right = of var](para){Formal parameters}; \node[terminal, right = of para](colon1){:}; \node[nonterminal, right = of colon1](type1){Type name}; \node[terminal, right = of type1](right){)}; \node[terminal, right = of right](colon2){:}; \node[nonterminal, right = of colon2](type2){Type name}; \node[terminal, right = of type2](semicolon1){;}; \node[terminal, below = of para](semicolon2){;}; % ---------------------------------------------------------- \draw[arrow1](function)--(name1); \draw[arrow1](name1)--(left); \draw[arrow1](left)--(var); \draw[arrow1](var)--(para); \draw[arrow1](para)--(colon1); \draw[arrow1](colon1)--(type1); \draw[arrow1](type1)--(right); \draw[arrow1](right)--(colon2); \draw[arrow1](colon2)--(type2); \draw[arrow1](type2)--(semicolon1); \draw[arrow1]($ (var.west)+(-3mm, 0) $)--++(0, 6mm)-|($ (var.east)+(3mm, 0) $); \draw[arrow1]($ (type1.east)+(3mm, 0) $)|-(semicolon2); \draw[arrow1](semicolon2)-|($ (var.west)-(3mm, 0) $); \draw[arrow1]($ (name1.east)+(3mm, 0) $)--++(0, -20mm)-|($ (right.east)+(3mm, 0) $); % ---------------------------------------------------------- \node[nonterminal, below = 2.7cm of function, xshift = 1cm](description){Description section}; \node[terminal, right = of description](begin){BEGIN}; \node[nonterminal, right = of begin, text width = 1.6cm](statement){Statement}; \node[terminal, right = of statement](semicolon3){;}; \node[terminal, right = of semicolon3, text width = 1.6cm](end){END}; \node[terminal, right = of end](semicolon4){;}; % ---------------------------------------------------------- \draw[arrow1](description)--(begin); \draw[arrow1](begin)--(statement); \draw[arrow1](statement)--(semicolon3); \draw[arrow1](semicolon3)--(end); \draw[arrow1](end)--(semicolon4); \draw[arrow1](semicolon4)--++(30pt, 0); \draw[arrow1](semicolon1)--++(0, -2.5cm)-|(description); \draw[arrow1]($ (semicolon3.east)+(3mm, 0) $)--++(0, -6mm)-|($ (begin.east)+(3mm, 0) $); \end{tikzpicture} \end{minipage}
|