00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef PARSER_AUTOMATON_H
00020 #define PARSER_AUTOMATON_H
00021
00022 #include <iostream.h>
00023
00024 #include "MNList.h"
00025 #include "MNArray.h"
00026 #include "dictionary.h"
00027
00028 #include "V2States.h"
00029
00030 class Action;
00031 class TargetState;
00032 class V1StateVector;
00033 class V2StateCollector;
00034 class StateTransitionArray;
00035
00036
00037
00038
00039
00040 class StateTransitionPair
00041 {
00042 MNList<V2StateVector*> _vectors;
00043 public:
00044 StateTransitionPair( );
00045
00046 void append( int dim_count, int* vector );
00047 void append( V2StateVector* v );
00048
00049 MNList<V2StateVector*>& vectors();
00050 };
00051
00052
00053
00054
00055
00056 class StateTransitionCollection
00057 : public MNdictionary<V1Transition*,StateTransitionPair*>
00058 {
00059 public:
00060 virtual int compare(V1Transition *const & l, V1Transition *const & r) const;
00061 };
00062
00063
00064
00065
00066
00067 class Automaton
00068 {
00069 bool _sync_stop;
00070
00071 const char* _user_code_header;
00072 const char* _user_header;
00073 const char* _user_class_elements;
00074 const char* _user_code;
00075 const char* _inherit_class;
00076 const char* _inherit_class_init;
00077 const char* _constructor_parameters;
00078 const char* _constructor_parameter_assignment;
00079 const char* _constructor_body;
00080 const char* _destructor_body;
00081 const char* _entertrans_code;
00082 const char* _enterstate_code;
00083
00084 int _user_code_header_line;
00085 int _user_header_line;
00086 int _user_class_elements_line;
00087 int _user_code_line;
00088
00089 V2StateCollector* _collector;
00090
00091 char* _automaton_name;
00092 char* _automaton_class_name;
00093 char* _target_file_name;
00094 char* _source_file_name;
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105 dictionary<int,SignalParameterList*> _inputname_to_input_definition;
00106
00107 void dump_nextstate_macro_recurse( ostream& ostr, int dim, int maxd, int* vector );
00108 void dump_nextstate_macro( ostream& ostr, int del, StateTransitionArray* array );
00109 void dump_nextstate_impl( ostream& ostr, StateTransitionArray* array );
00110 void dump_statename_impl( ostream& ostr, StateTransitionArray* array );
00111 void dump_enterstate_impl( ostream& ostr );
00112 void dump_entertrans_impl( ostream& ostr );
00113 void dump_user_header ( ostream& );
00114 void dump_user_code_header ( ostream& );
00115 void dump_user_class_elements ( ostream& );
00116 void dump_state_enum( ostream&, StateTransitionArray* array );
00117 void dump_input_enum( ostream& );
00118 void dump_input_calls( ostream& ostr, int decl, StateTransitionArray* array );
00119 void dump_signal_calls( ostream& ostr, int decl, StateTransitionArray* array );
00120 void dump_signal_classes( ostream& ostr, int decl );
00121 void dump_constructor( ostream& ostr, int decl );
00122 void dump_user_code( ostream& ostr );
00123 public:
00124 Automaton();
00125 void setName ( const char* s );
00126
00127 void setFilename ( int prefix );
00128 void setCodePrefix ( const char* prefix, int codeblockline );
00129 void setPrefix ( const char* prefix, int codeblockline );
00130 void setDeclare ( const char* declaration, int codeblockline );
00131 void setDefine ( const char* definition, int codeblockline );
00132 void setInherit ( int inherit_class );
00133 void setInherit ( int inherit_class, const char* inherit_class_init );
00134 void setInherit ( const char* inherit_class );
00135 void setInherit ( const char* inherit_class, const char* inherit_class_init );
00136 void setConstruct ( const char* parameters,
00137 const char* assignment = NULL,
00138 const char* body = NULL );
00139 void setDestruct ( const char* body );
00140 void setEnterstate ( const char* body );
00141 void setEntertrans ( const char* body );
00142 void setSyncStop ( );
00143 void inputDefinition ( int name, SignalParameterList* parameters );
00144
00145 void respace ( ostream& ostr,
00146 const char* str,
00147 const char* input );
00148
00149 void eval ( V2StateCollector* v2, StateTransitionArray* array );
00150 };
00151
00152 extern Automaton automaton;
00153
00154 #endif
00155