Saved Files Format

JFLAP will read saved files generated by older versions properly, but older versions may not be able to load the new JFLAP saved files.

Note that each line should be exactly as specified below, without blank or extra lines at the beginning or between lines. Words can be separated by 1 or more spaces or even tabs if desired. Trailing data (except spaces) like comments at the end of lines should NOT be used. On some lines it will not be ignored. If data on a line is larger than your screen it should still be on 1 line only. (beware of text editors that will automaticly break up your lines)


Format of Automata Files:

The first line of the file contains a string corresponding to the type of the machine.

The following line should contain a single integer indicating the number of states in the machine.

The next line should contain only a "#". The only purpose of this line is to maintain compatibility with older JFLAP files which had the alphabet stored on this line. It can be used to put a comment in the file if you so desire since it is ignored. PDAs and Turing machines require a second line with a "#" on it.

The next line contains the number of the initial state (so if the initial state was the third state it would be 3) or a "0" if there is no initial state. Note that this number is the position of the initial state in the list, NOT the number on its label. For example if your machine has 3 states "q0" "q5" and "q8" and "q5" is the initial state then the number would be 2.

The next line contains a list of the final states, indicated by their position, and terminated by a "0". Note that if there are no final states the "0" should still be present. Example: "3 5 0" would mean states 3 and 5 are final, or just "0" would mean there are no final states

The next X lines represent the transitions leaving from each state, where X is the number of states (indicated on the second or 4th line of the file depending on the type of machine) The format for transitions is different for each machine, but for all machines all transitions are stored one after the other on the line, terminated by the string "EOL":

For FSAs, the line should contain the transitions's label, followed by the number of the state that the transition leads to. Example: a transition labeled "ab" going to state 5 would be: "ab 5"

For PDAs, the line should contain the input to read followed by the string to pop from stack, followed by the string null, followed by the state this transition leads to, followed by the string to push on the stack. Example: a transition labeled "a,b;c" going to state 4 would be: "a b null 4 c"

For 1 tape TMs, the line should contain the symbol to read, followed by the state this transition leads to, followed by the symbol to write, followed by the direction (R, L or S). Example: a transition labeled "a;b,c" leading to state 5 would be: "a 5 b c"

For 2 tape TMs, the line should contain (on one line separated by spaces)

Example: In an FSA if a state had two transitions labeled "abc" and "d" leading respectively to states 3 and 4 the whole line would be: "abc 3 d 4 EOL"

A state with no transitions should just have a line containing "EOL". Note that if any part of a transition's label is empty, treat it as if it contained the string "null". Example: a lambda transition in an FSA has no label. A lambda transition to state 5 would be represented with: "null 5"

This can get rather long with a 2 tape TM that has several transitions, but it still has to fit on one line!

The following X lines (where X is the number of states) represent the states. They should contain the state's name "q5" followed by the state's coordinates on the machine's display (x and y) and the size of its loop. Note that (0,0) is in the upperleft corner of the display and the default size is 700 by 409 pixels. The loop size is the size of the arrow for transitions leading from this state back into this state. For states who do not have such transitions the value should be 0. Example: if state "q5" is located at x:200 and y:300 then its line would be: "q5 200 300 0" if it also had a loop of size 70 then it woudl be: "q5 200 300 70"


The last Y lines (where Y is the number of transitions) represent the placement ratio for each of the transition's label. This ratio is:
(distance from start state) / (distance between start and end state)
These Y lines can be skipped and all ratio values will default to .5.

Note that state names always have to be made of the letter "q" followed by a positive integer.


Here is an example of a simple FSA saved file, with added comments (do not add comments to your files, this is just for making the example easier to understand)

One-Way-FSA //name of the machine type
4 //number of states
# //stub line
1 //initial state is "q0"
2 0 //"q1" is the only final state
a 2 b 3 EOL // two transitions from first state. One leading to state
// "q1" with label "a" and one leading to state "q2" with
// label "b"
EOL
EOL //no transitions from the third state
EOL
q0 30 206 0
q1 243 91 0 //the second state is called "q1" and is located at (243, 91)
q2 202 312 0
q3 489 122 0
.5 // both transitions labels are located in the center
.5

Here is an example of a simple 2 tape TM with added comments:

REGTM //name of machine type: TM
TAPE //TAPE keyword
2 // 2 tape TM
4 //number of states
#
# // 2 stub lines
2 //initial state is "q1"
0 //no final states
a 4 b c null e f EOL //transition from first state labeled "a;b,c|;e,f" leading to
// state "q3"
EOL
EOL //no transitions from this state
EOL
q0 47 275 0
q1 244 140 0
q7 507 149 0 //the third state is labeled q8
q8 274 321 0
.25 //this transition label was placed closer to its start state

Here is an example of a simple PDA without comments:

PDAP
FINAL
3
#
#
1
0
a b null 2 c EOL
EOL
EOL
q0 148 214 0
q1 336 90 0
q2 393 222 0


Format of Grammar Files:

Grammars are also saved in JFLAP 3.0 from the Grammar input window. They should end with ".GRM" to indicate that they are grammar files.

The first line of a saved grammar will start with a "#" and is a comment. You may choose to put any desired information here.

The following lines each represent 1 rule of the grammar. All terminals should be lowercase letters, and all variables should be uppercase letters. The variable on the left of the first rule will be assigned as the start symbol.

Each rule is saved in the following format. Note that spaces are important:
<variable> -> <list of variables and terminals>

Example:
A -> aBc

In the case of a lambda/epsilon transition, simply leave the right hand empty. Example:
A ->


Format of Regular Expression Files:

Regular Expressions can be saved through the Regular Expression Input Window. They should end with ".REX" to indicate that they are Regular Expression files.

The first line of a saved grammar will start with a "#" and is a comment. You may choose to put any desired information here.

The following line is the regular expression that has been saved.