------------------------------------------------------ Results of the July 7 2003 brainstorming on DFA vs NFA ------------------------------------------------------ -- 1 abstract class FA -- 3 child classes extending FA: NFA, DFA, MinDFA -- FA must contain a list of accepting states. This list will make it easier to implement oneOrMore, zeroOrMore, etc... In a small NFA, this list will often contain only one element. -- When we generate a DFA based on a given NFA, we can get rid, in a manner of speaking, of the NFA -> BUT we have to keep track of the following information when it comes to accepting states: we have to know what type of thing the state accepts. Does it accept a "number', an "id", an "expr", etc. We will probably need a string variable "accept", among other things, to contain that information... -- We will probably need to have an external interval manager that will deal, among other things, with intersections. -- In order to lessen the work of the garbage collector, when generating a new FA (DFA or NFA) based on 2 existing FAs (DFA and/or NFA), it is better to combine the 2 existing "FAs" in order to make a new one than to copy the content of the 2 "FAs" into the new FA and then discart the old FAs. We can think of it as "recycling" the old FAs. The current implementation of Sablecc does not take this into account. -- We will have to keep the use of arrays to a minimum. -- We will have to think about a "reduceCharset()" method that will deal with identical charsets when we construct a minDFA, but NOT when we construct a DFA or a NFA ... -- Use of pointers to datastructures... -- NFA, DFA, FA, minDFa should probably be in package "org.sablecc.sablecc.regular". ------------- -- Methods -- ------------- -that should be in FA : - methods that tell us what is the internal representation : - R U a DFA ? - R U a NFA ? - boolean isActive() (or isValide())... - methods combining 2 "FAs" (DFA and / or NFA) : NOTE: It is important to keep in mind that if we deal with 2 FAs that are either 2 NFAs or 1 NFA and 1 DFA, transitions on empty strings will be permited. The resulting FA will thus be a NFA. If, however, the 2 FAs are in fact 2 DFAs, the resulting FA will be a DFA, which means that there will be no transitions on empty strings in the resulting FA. - public void zeroOreMore () - public void zeroOrOne () - public void oneOrMore () - public void concatenate (FA fa) - public void or (FA fa), known as "alternate" in the current version of Sablecc. - public void merge (FA fa) - ... - general purpose methods : - String toString() - ... -that should be in NFA : - Various constructors - To be determined... - methods that modify the internal representation : - DFA toDFA (), (it should call one of the DFA constructors...) -that should be in DFA : - Various constructors - To be determined... - methods that modify the internal representation : - MinDFA toMinDFA () - general purpose methods : - String toString() - ... - other methods : - computeEclosure() - various eclosure() functions and/or procedures - ... -that should be in MinDFA : - Various constructors - To be determined... - general purpose methods : - String toString() - ... - other methods : - optimize() - reduceCharset() - When it comes to accepting tokens, we should find a way that is flexible enough so that