diff --git a/README.md b/README.md index 90a4655..5f36ed5 100644 --- a/README.md +++ b/README.md @@ -239,9 +239,11 @@ Execution starts at the start state of the base automaton. A stack of states is A sequence of input symbols is recognized if this process leaves us in an accepting state of the base automaton. -Here's a quick drawing of what the two automata look like for this [grammar of nested arrays](https://ianh.github.io/owl/try/#nested): `a = [ '[' (a (',' a)*)? ']' ]`. +Here's a visual representation of what the two automata look like for this [grammar of nested arrays](https://ianh.github.io/owl/try/#nested): -| | | +`a = [ '[' (a (',' a)*)? ']' ]` + +| | | | :---: | :---: | | *base automaton* | *bracket automaton* | diff --git a/doc/automata.tex b/doc/automata.tex new file mode 100644 index 0000000..8e66cc1 --- /dev/null +++ b/doc/automata.tex @@ -0,0 +1,45 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% PREAMBLE +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\documentclass[11pt]{article} + +% packages needed for state diagrams +\usepackage{pgf} +\usepackage{tikz} +\usetikzlibrary{arrows,automata} + +% page margins +\usepackage[margin=2.5cm]{geometry} +\setlength{\parindent}{0pt} + +\begin{document} + +\begin{center} + \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,semithick] + \tikzstyle{every state}=[fill=white,draw=black,text=black] + \node[initial,state] (s0) {}; + \node[state,accepting] (s1) [right of=s0] {}; + \path + (s0) edge node {$[\ ]_{,}$} (s1); + \end{tikzpicture} +\end{center} + +\bigskip + +\begin{center} + \begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2.8cm,semithick] + \tikzstyle{every state}=[fill=white,draw=black,text=black] + \node[initial,state] (s0) {}; + \node[state] (s1) [right of=s0] {}; + \node[state] (s2) [below of=s1] {}; + \node[state] (s3) [below of=s2] {}; + \node[state,accepting,rectangle] (s4) [right of=s1] {$[\ ]_{,}$}; + \path + (s0) edge node {[} (s1) + (s1) edge node {]} (s4) edge node {$[\ ]_{,}$} (s2) + (s2) edge [bend right] node [swap] {'} (s3) edge [bend right] node {]} (s4) + (s3) edge [bend right] node [swap] {$[\ ]_{,}$} (s2); + \end{tikzpicture} +\end{center} +\end{document} diff --git a/doc/base-automaton.png b/doc/base-automaton.png index aa6a207..9954dc0 100644 Binary files a/doc/base-automaton.png and b/doc/base-automaton.png differ diff --git a/doc/bracket-automaton.png b/doc/bracket-automaton.png index 1e9692c..d0fa18a 100644 Binary files a/doc/bracket-automaton.png and b/doc/bracket-automaton.png differ