Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve automata diagrams #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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):

| <img src="doc/base-automaton.png" width=162 height=57> | <img src="doc/bracket-automaton.png" width=225 height=187> |
`a = [ '[' (a (',' a)*)? ']' ]`

| <img src="doc/base-automaton.png"> | <img src="doc/bracket-automaton.png"> |
| :---: | :---: |
| *base automaton* | *bracket automaton* |

Expand Down
45 changes: 45 additions & 0 deletions doc/automata.tex
Original file line number Diff line number Diff line change
@@ -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}
Binary file modified doc/base-automaton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified doc/bracket-automaton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.