typedefshort setToLabelsType; /* for srec field member - may wish to change this */ typedefstruct srec { /* This mirrors the set record type defined in the GAP format. *Wewon'trequirethe`format'fieldhere,sincenameswillalwaysbe *storedasasimplelist. *Inthe`word'type,thenameswillbestoredasstringsof`gen's, *andthebasecomponentshouldbeoftypeidentifiers,wherenumberi *inthestringcorrespondstothenameofidentifiernumberiinthe *base.nameslist. *Alistofintegerisstoredasasimplelistprecededbyitslength.
*/
srec_type type; int size; char **names; /* Used with identifiers or strings */
gen **words; /* The type gen is used with words */
gen ***wordslist; /* For list of words type - if wordslist[i] contains *nwords,thesewillbestoredinwordslist[i][j] *for0<=j<n,withwordslist[i][n]setto0.
*/ int **intlist; /* For list of integers type - if intlist[i] is a list of *lengthn,thentheintegerswillbestoredasintlist[i][j] *for1<=j<=n,withintlist[i][0]=n.
*/ int arity; /* for product type */ char padding; /* for product type - the printing char. for padding symbol */ char *alphabet[MAXGEN + 1]; /* names of base-alphabet for words */ int alphabet_size; /* length of base-alphabet for words */ struct srec *base; /* for product type */ struct srec *labels; /* for labeled type */
setToLabelsType *setToLabels; /* for labeled type */
} srec;
typedefstruct { /* This is used to store the transition table of a finite state automaton. *Thedatastructuredependsonthetable_type. *Currently,therearetwomaintypes,denseandsparse *denseisthesimplestandfastest-entriesarestoredina2-dimensional *arraystructure,withrowscorrespondingtogenerators.Itcanbe *expensiveintermsofspace. *Denseformatcanonlybeusedfordeterministicmachines(the *densenondeterministictypeisnotyetimplemented). *Insparsestorage,thetransitionsfromagivenstatearestoredin *asequenceofmemorylocations,witheachtransitiontakinguptwo *locations,thefirstageneratorandthesecondthetargetofthe *transitionfromthegivenstatewiththatgeneratoraslabel. *Thereisapointertothissequenceoflocationsforeachstate. *sparseformatisnotsuitableifnewtransitionsneedtobeadded *fromagivenstateoncethestructurehasbeensetup. *Ifthestoragetypeissparse,butthe"dense_rows"fieldisapositive *integern,thenthetransitionsforthefirstnstatesarestordindense *format,andtheremainderinsparseformat.Thiscompromisehopefully *allowsreasonablyfastaccesswithoutusingtoomuchspace-thisisbased *ontheassumptionthattherewillbemosttransitionsforthestateswith *thesmallestnumbers.Thedefaulttargetmechanismisnotyetimplemented- *ifreadfromaninputfile,theinformationwillbeinsertedintothe *table.anddenseformatwillbeused.Ifthefilenamepointerisnonzero, *thenthetransitiontableisnotpresentinthefileatall-itisstored *externallyinunformattedforminthefile*filename(possiblywithother *information).2/10/97-athirdstoragetype,compactisadded.Thisisas *insparse,buteach(generator,state)pairisstoredinasingle4-byte *word,withthegeneratorstoredinthefirstbyte.(Sowehaveamaximumof *256edge-label.)
*/ char *filename;
storage_type table_type;
storage_type printing_format; /* This specifies the format for printing, which may not be the same as *thatforstoring-againdenseonlyapplicabletodfa's.
*/
boolean comment_state_numbers; /* If this is set true, then when printing the table, the entry *correspondingtoeachstateisfollowedbyacommentgivingthe *numberofthatstate.Thisistoincreasereadabilityofthetable.
*/ int numTransitions; /* The number of nonzero transitions in the table. *Usedmainlywhenreadingin.
*/ int maxstates; /* The maximum number of states for which space has been *allocated *Onlyreallymeaningfulfordensestoragetype.
*/ int denserows; /* Only applies in sparse storage type - the number of states *forwhichthetransitionsarestoredensely.
*/ int **table_data_ptr; /* This field is used for setting and accessing the transitions. *Itsusagewilldependonthestoragetype. *Letkbethetargetofthetransitionfromstateiwithletterj. *Fortypedense,kwillbeaccessedastable_data_ptr[j][i]. *Fortypesparse,table_data_ptr[i]pointstoalocationintable_data *whichisthebeginningofthesequenceoftransitionsfromstatei. *NOTETHISFUNDAMENTALDIFFERENCE-forsparsetype,the'i'isa *statenumber,butfordensetype,itwouldbeanedgenumber. *Insparsetype,fori<=denserows,table_data_ptr[i][j]=k. * *Inallcases,table_data_ptr[0]willpointatthebeginningofthe *data.
*/ int ***table_data_dptr; /* table_data_dptr is only used for dense storage of 2-variable *automata,whenitisdefinedtomaketable_data_dptr[i1][i2][j] *thetargetofthetransitionfromthestatejwithedge-label *thepair(i1,i2)-thisispurelyforspeedofaccess. *NOTEThislastfieldshouldbesetwheneverrequiredusingthe *functionfsa_table_dptr_init().
*/ unsignedint **ctable_data_ptr; /* For the compact form of data storage */
} table_struc;
typedefstruct { /* This mirrors the finite state automaton type in the GAP format.
*/
srec *states;
srec *alphabet; int num_initial; /* The number of initial states. *Thelistitselfissetwheneverthisisnonzero.
*/ int *initial;
boolean *is_initial; /* this array is only set when required. *Itshouldbedeallocatedimmediatelyafteruse.
*/ int num_accepting; /* The number os accepting states. If this number is *equalto0orstates->size>1,thenthelistitself *acceptingneednotbeset.
*/ int *accepting;
boolean *is_accepting; /* this array is only set when required. *Itshouldbedeallocatedimmediatelyafteruse.
*/
boolean *is_accessible; /* this array is only set when required. *Itshouldbedeallocatedimmediatelyafteruse.
*/
boolean flags[num_kbm_flag_strings]; /* set to TRUE if corresponding flag is set. *theentriescorrespondtoflag_list
*/
table_struc *table;
} fsa;
/* The following macros should be used for accessing and setting transition *targetsoutsideofthefilefsa.c. *Theyhavebeendesignedtoprovideastableaccess,whilststillbeing *reasonablyfast-becausefastaccessoftableentriesisextremely *time-criticalinmanyapplications. *"dense"isintendedtobeabooleansettotrueifthestoragetypeof *thetableisdense,andfalseifsparse. *"table"shouldbethetable_data_ptrfieldineithercase. *"denserows"shouldbesetequaltothedenserowscomponentofthetable. *"e"istheedge-numberand"s"thestatenumberforwhichthetarget *stateisrequired. *Forsparseformat,thefunctionsparse_target(infsa.c)iscalled. *Usedense_targetwhenthestoragetypeisknowntobedense.
*/ #define target(dense, table, e, s, denserows) \
(dense ? table[e][s] \
: s <= denserows ? table[s][e] \
: sparse_target(e, table[s], table[s + 1])) #define dense_target(table, e, s) (table[e][s]) #define set_dense_target(table, e, s, t) (table[e][s] = t)
/* The next two are for accessing and setting targets for 2-variable *fsa'sstoredindensetype. *"dtable"shouldbesetequaltothetable_data_dptrfield.
*/ #define dense_dtarget(dtable, g1, g2, s) (dtable[g1][g2][s]) #define set_dense_dtarget(dtable, g1, g2, s, t) (dtable[g1][g2][s] = t)
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.