jflap2tikz

Upload: john-william-vasquez-capacho

Post on 05-Apr-2018

222 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 JFlap2Tikz

    1/6

    JFlap2TikZ

    Andrew Mertz and William Slough

    Introduction

    JFlap is an excellent piece of software for experimenting with finite state machines, Turing machines andexploring many aspects of the theory of computation. JFlap2TikZ is a groovy script that converts a JFlapjff file representing a finite automaton, push down automaton, or Turing machine to LATEX file depictingthe automaton graphically using TikZ.

    Requirements

    To use JFlap2TikZ you will need Java installed. Additionally you may find it useful to have groovy in-

    stalled as well. You will need to download either JFlap2TikZ.jar (if you only have Java installed) orJFlap2TikZ.groovy (if you also have groovy installed).

    Usage

    JFlap2TikZ is invoked from the command line, using Java

    java -jar JFlap2TikZ.jar example.jff

    or using groovy

    groovy JFlap2TikZ.groovy example.jff

    Note that in either case the output will be written to the console. Redirect the output or copy and paste asneeded. Here is the full usage information.

    usage: JFlap2TikZ [-g] [-h] [-r] [-s scale] [-z size] filename

    -g,--grid Round positions so that they are on a grid

    -h,--help Show usage information and quit

    -r,--rotate rotate labels along edges

    -s,--scale 1 pixel in JFlap = scale points in LaTeX (default

    is 1.0)

    -z,--gridsize Set the spacing of the grid (default is 20.0)

    Examples

    The following figures show machines from the book JFLAP: An Interactive Formal Languages and AutomataPackage being converted to TikZ using JFlap2TikZ. Note that JFlap2TikZ currently ignores JFlap stateannotations. Furthermore, not all JFlap files will be converted perfectly. You may have to adjust the scaleand/or gridsize or edit the resulting TikZ code to achieve the effect you want. However, JFlap2TikZ shouldprovide a good starting point.

    http://www.jflap.org/http://groovy.codehaus.org/http://www.java.com/http://groovy.codehaus.org/http://www.jflap.org/jflapbook/http://www.jflap.org/jflapbook/http://www.jflap.org/jflapbook/http://www.jflap.org/jflapbook/http://groovy.codehaus.org/http://www.java.com/http://groovy.codehaus.org/http://www.jflap.org/
  • 8/2/2019 JFlap2Tikz

    2/6

    JFlap2TikZ v1.0 2

    Figure 1: ex0.1a.jff

    q3

    q2

    q1

    q0

    a

    b

    a

    a

    Figure 2: ex0.1a.jff converted to TikZ using default values

  • 8/2/2019 JFlap2Tikz

    3/6

    JFlap2TikZ v1.0 3

    q3

    q2

    q1

    q0

    a

    b

    a

    a

    Figure 3: ex0.1a.jff converted to TikZ using a scale of 2

    q3

    q2

    q1q0

    a

    b

    a

    a

    Figure 4: ex0.1a.jff converted to TikZ using a gridsize of 100

  • 8/2/2019 JFlap2Tikz

    4/6

    JFlap2TikZ v1.0 4

    Figure 5: ex9-anbncn.jff

  • 8/2/2019 JFlap2Tikz

    5/6

    JFlap2TikZ v1.0 5

    q2

    q7

    q5

    q0

    q3

    q9

    q10 q4

    q1

    q8 q6

    c:

    l

    ,L

    a : a, Lb : b, Lc : c, L

    a : a, Lb : b, Lc : c, L

    # : #, L

    l : l , R

    c : c, R

    b : b, R

    # : #, R

    a : a, R

    # : #, R

    c : c, Rb : b, Ra : a, R

    #: #

    , R

    l

    :l

    ,R

    l

    : l, L

    a:

    l

    ,R

    b : #, R

    #:#,R

    l : l , L

    c:c,

    R

    b : #, R

    l

    :

    l

    ,S

    l

    :l , L

    Figure 6: ex9-anbncn.jff converted to TikZ using a gridsize of 50 and label rotations on

  • 8/2/2019 JFlap2Tikz

    6/6

    JFlap2TikZ v1.0 6

    License

    JFlap2TikZ and its documentation are licensed under an MIT style license

    Copyright (c) 2009, Andrew Mertz and William Slough

    Permission is hereby granted, free of charge, to any person obtaining a copy

    of this software and associated documentation files (the "Software"), to deal

    in the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sell

    copies of the Software, and to permit persons to whom the Software is

    furnished to do so, subject to the following conditions:

    The above copyright notice and this permission notice shall be included in

    all copies or substantial portions of the Software.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

    THE SOFTWARE.