|
| 1 | +#File Formats |
| 2 | + |
| 3 | +A documentation of the file formats read and written by this library. |
| 4 | + |
| 5 | +-[File Formats](#file-formats) |
| 6 | +- [Automatas](#automatas) |
| 7 | +- [Course specific](#course-specific) |
| 8 | +- [Examples](#examples) |
| 9 | +- [Context Free Grammars](#context-free-grammars) |
| 10 | +- [JFLAP](#jflap) |
| 11 | +- [Course specific](#course-specific-1) |
| 12 | +- [Examples](#examples-1) |
| 13 | + |
| 14 | +##Automatas |
| 15 | + |
| 16 | +###Course specific |
| 17 | + |
| 18 | +This library can read a format specific to the related course, it works like |
| 19 | +this. |
| 20 | + |
| 21 | +* One line with the alphabet, and`ε` if it's a ε-NFA, separated by separated |
| 22 | +by whitespace(s). |
| 23 | +* And one line per state. Each line should contain the following information in |
| 24 | +the following order, separated by whitespace(s). |
| 25 | +* The UTF-8 character`→` or`->` if this is the start state. |
| 26 | +* A`*` if this is a accepting state. |
| 27 | +* The name of the state. One or more non-whitespace characters. |
| 28 | +* Then comes the transitions, in a order corresponding to the symbols of the |
| 29 | + alphabet on the first line. |
| 30 | + If there are multiple transitions, as can be the case for NFAs and ε-NFAs, |
| 31 | + all transitions for one symbol should be surrounded by`{``}`, and |
| 32 | + separated by whitespace(s). The UTF-8 character`∅` can be used to |
| 33 | + represent empty sets. |
| 34 | + |
| 35 | +Comments are allowed, everything after a`#` is ignored. |
| 36 | + |
| 37 | +####Examples |
| 38 | + |
| 39 | +A DFA: |
| 40 | +``` |
| 41 | + a b c |
| 42 | +→ * s₀ s₁ s₀ s₂ |
| 43 | + s₁ s₂ s₁ s₁ |
| 44 | + * s₂ s₂ s₂ s₂ |
| 45 | +``` |
| 46 | + |
| 47 | +A NFA: |
| 48 | +``` |
| 49 | + a b c |
| 50 | +→ s₀ {s₀} {s₁} {s₀ s₂} |
| 51 | + s₁ ∅ {s₃} {s₂} |
| 52 | + s₂ ∅ {s₁} {s₄} |
| 53 | + s₃ {s₄} ∅ {s₃} |
| 54 | +* s₄ ∅ {s₄} ∅ |
| 55 | +``` |
| 56 | + |
| 57 | +And a ε-NFA: |
| 58 | +``` |
| 59 | + ε a b |
| 60 | +→ s₀ ∅ {s₁} {s₀ s₂} |
| 61 | + s₁ {s₂} {s₄} {s₃} |
| 62 | + s₂ ∅ {s₁ s₄} {s₃} |
| 63 | + s₃ {s₅} {s₄ s₅} ∅ |
| 64 | + s₄ {s₃} ∅ {s₅} |
| 65 | +* s₅ ∅ {s₅} {s₅} |
| 66 | +``` |
| 67 | + |
| 68 | +##Context Free Grammars |
| 69 | + |
| 70 | +###JFLAP |
| 71 | + |
| 72 | +This library can read the XML file format`.jff` of[JFLAP](http://www.jflap.org/). |
| 73 | +This has been tested with the JFLAP 4 format. |
| 74 | + |
| 75 | +###Course specific |
| 76 | + |
| 77 | +It can also read a format specific to the related course, it works like this. |
| 78 | + |
| 79 | +Each production of the grammar is written on one line starting with the |
| 80 | +non-terminal "name" of the production. Followed by the UTF-8 character`→`. |
| 81 | +After that all the alternative of the production is listed, separated by a bar |
| 82 | +`|`. |
| 83 | + |
| 84 | +**Note**: Non-terminals must be single uppercase letter (A-Z), all other |
| 85 | +characters are considered to be terminals with one exception. The UTF-8 |
| 86 | +character`ε` is used to represent the empty string. |
| 87 | + |
| 88 | +####Examples |
| 89 | + |
| 90 | +``` |
| 91 | +E→EOE|N |
| 92 | +O→+|-|ε |
| 93 | +N→1|1N |
| 94 | +``` |