COPASI API  4.16.103
CChemEqParser.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/model/CChemEqParser.h,v $
3 // $Revision: 1.5 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/05/26 12:25:41 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CChemEqParser
24 #define COPASI_CChemEqParser
25 
26 #include <vector>
27 #include <string>
28 
29 #undef yyFlexLexer
30 #include "FlexLexer.h"
31 
32 #define yyFlexLexer CChemEqParser
33 
34 #undef yyYaccParser
35 #define yyYaccParser CChemEqParserBase
36 
37 #undef YYDEBUG
38 #ifdef COPASI_DEBUG
39 # define YYDEBUG 0 // Set this different from zero to trace the parser
40 #else
41 # define YYDEBUG 0
42 #endif // COPASI_DEBUG
43 
44 /**
45  * This is a base class for the CChemEqParser adding member
46  * attributes to enhance the internal functionality.
47  */
49 {
50 public:
51  /**
52  * Default constructor
53  */
54  yyYaccParser();
55 
56  /**
57  * Destructor
58  */
59  virtual ~yyYaccParser();
60 
61  virtual int yylex() = 0;
62 
63  virtual int yyparse();
64 
65  const bool & isReversible() const;
66 
67  const std::vector< std::string > & getSubstrateNames() const;
68  const std::vector< C_FLOAT64 > & getSubstrateMulitplicities() const;
69  const std::vector< std::string > & getSubstrateCompartments() const;
70 
71  const std::vector< std::string > & getProductNames() const;
72  const std::vector< C_FLOAT64 > & getProductMulitplicities() const;
73  const std::vector< std::string > & getProductCompartments() const;
74 
75  const std::vector< std::string > & getModifierNames() const;
76  const std::vector< C_FLOAT64 > & getModifierMulitplicities() const;
77  const std::vector< std::string > & getModifierCompartments() const;
78 
79 protected:
80  void correctErrorPosition();
81 
82  // Attributes
83 public:
84  struct Data
85  {
86  std::string name;
88  std::string compartment;
89  };
90 
91 protected:
93 
94  unsigned C_INT32 mPosition;
96 
97  std::vector< std::string > mSubstrateNames;
98  std::vector< C_FLOAT64 > mSubstrateMult;
99  std::vector< std::string > mSubstrateCompartments;
100 
101  std::vector< std::string > mProductNames;
102  std::vector< C_FLOAT64 > mProductMult;
103  std::vector< std::string > mProductCompartments;
104 
105  std::vector< std::string > mModifierNames;
106  std::vector< C_FLOAT64 > mModifierMult;
107  std::vector< std::string > mModifierCompartments;
108 };
109 
110 class CChemEqParser: public FlexLexer, public yyYaccParser
111 {
112 public:
113  // arg_yyin and arg_yyout default to the cin and cout, but we
114  // only make that assignment when initializing in yylex().
115  CChemEqParser(std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0);
116 
117  virtual ~CChemEqParser();
118 
119  void yy_switch_to_buffer(struct yy_buffer_state* new_buffer);
120 
121  struct yy_buffer_state* yy_create_buffer(std::istream* s, int size);
122 
123  void yy_delete_buffer(struct yy_buffer_state* b);
124  void yyrestart(std::istream* s);
125 
126  void yypush_buffer_state(struct yy_buffer_state* new_buffer);
127  void yypop_buffer_state(void);
128 
129  virtual int yylex();
130  virtual void switch_streams(std::istream* new_in, std::ostream* new_out);
131  virtual int yywrap();
132 
133 protected:
134  virtual int LexerInput(char* buf, int max_size);
135  virtual void LexerOutput(const char* buf, int size);
136  virtual void LexerError(const char* msg);
137 
138  void yyunput(int c, char* buf_ptr);
139  int yyinput();
140 
141  void yy_load_buffer_state();
142 
143  void yy_init_buffer(struct yy_buffer_state* b, std::istream* s);
144 
145  void yy_flush_buffer(struct yy_buffer_state* b);
146 
150 
151  void yy_push_state(int new_state);
152  void yy_pop_state();
153  int yy_top_state();
154 
157  int yy_get_next_buffer();
158 
159  std::istream* yyin; // input source for default LexerInput
160  std::ostream* yyout; // output sink for default LexerOutput
161 
163 
164  // yy_hold_char holds the character lost when yytext is formed.
166 
167  // Number of characters read into yy_ch_buf.
169 
170  // Points to current character in buffer.
171  char* yy_c_buf_p;
172 
173  int yy_init; // whether we need to initialize
174  int yy_start; // start state number
175 
176  // Flag which is used to allow yywrap()'s to do buffer switches
177  // instead of setting up a fresh yyin. A bit of a hack ...
179 
180  size_t yy_buffer_stack_top; /**< index of top of stack. */
181  size_t yy_buffer_stack_max; /**< capacity of stack. */
182  struct yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
183  void yyensure_buffer_stack(void);
184 
185  // The following are not always needed, but may be depending
186  // on use of certain flex features (like REJECT or yymore()).
187 
190 
193 
197 
198  int yy_lp;
200 
205 };
206 
207 #endif // COPASI_CChemEqParser
size_t yy_buffer_stack_max
unsigned C_INT32 mPosition
Definition: CChemEqParser.h:94
yy_state_type yy_last_accepting_state
std::vector< std::string > mModifierCompartments
CChemEqParser(std::istream *arg_yyin=0, std::ostream *arg_yyout=0)
void yy_init_buffer(struct yy_buffer_state *b, std::istream *s)
std::ostream * yyout
yy_state_type yy_get_previous_state()
yy_state_type * yy_state_ptr
struct yy_buffer_state * yy_create_buffer(std::istream *s, int size)
void yyunput(int c, char *buf_ptr)
#define yyparse
virtual int yywrap()
#define C_INT32
Definition: copasi.h:90
size_t yy_buffer_stack_top
virtual void LexerOutput(const char *buf, int size)
virtual int LexerInput(char *buf, int max_size)
yy_state_type yy_try_NUL_trans(yy_state_type current_state)
std::vector< std::string > mProductNames
std::vector< C_FLOAT64 > mModifierMult
void yyrestart(std::istream *s)
int yy_state_type
Definition: FlexLexer.h:72
void yypop_buffer_state(void)
int yy_start_stack_depth
int * yy_start_stack
std::vector< C_FLOAT64 > mSubstrateMult
Definition: CChemEqParser.h:98
struct yy_buffer_state ** yy_buffer_stack
char * yy_last_accepting_cpos
virtual ~CChemEqParser()
std::vector< std::string > mSubstrateNames
Definition: CChemEqParser.h:97
virtual void LexerError(const char *msg)
#define yyYaccParser
Definition: CChemEqParser.h:35
std::vector< std::string > mSubstrateCompartments
Definition: CChemEqParser.h:99
void yy_push_state(int new_state)
void yyensure_buffer_stack(void)
void yy_delete_buffer(struct yy_buffer_state *b)
std::vector< C_FLOAT64 > mProductMult
virtual int yylex()
struct yy_buffer_state * yy_current_buffer
std::istream * yyin
void yy_flush_buffer(struct yy_buffer_state *b)
#define C_FLOAT64
Definition: copasi.h:92
char * yy_full_match
std::vector< std::string > mModifierNames
std::vector< std::string > mProductCompartments
void yypush_buffer_state(struct yy_buffer_state *new_buffer)
void yy_switch_to_buffer(struct yy_buffer_state *new_buffer)
virtual void switch_streams(std::istream *new_in, std::ostream *new_out)
int yy_did_buffer_switch_on_eof
int yy_looking_for_trail_begin
yy_state_type * yy_state_buf