src
Public Member Functions | Friends | List of all members
re2c::AltOp Class Reference

#include <regexp_alt.h>

Inheritance diagram for re2c::AltOp:
Inheritance graph
[legend]
Collaboration diagram for re2c::AltOp:
Collaboration graph
[legend]

Public Member Functions

 AltOp (RegExp *e1, RegExp *e2)
 
void split (std::set< uint32_t > &)
 
uint32_t calc_size () const
 
uint32_t fixedLength ()
 
nfa_state_tcompile (nfa_t &nfa, nfa_state_t *n)
 
void display (std::ostream &o) const
 
 FORBID_COPY (AltOp)
 
- Public Member Functions inherited from re2c::RegExp
 RegExp ()
 
virtual ~RegExp ()
 
 FORBID_COPY (RegExp)
 

Friends

RegExpmkAlt (RegExp *, RegExp *)
 

Additional Inherited Members

- Static Public Attributes inherited from re2c::RegExp
static free_list< RegExp * > vFreeList
 

Detailed Description

Definition at line 9 of file regexp_alt.h.

Constructor & Destructor Documentation

re2c::AltOp::AltOp ( RegExp e1,
RegExp e2 
)
inline

Definition at line 15 of file regexp_alt.h.

16  : exp1 (e1)
17  , exp2 (e2)
18  {}

Member Function Documentation

uint32_t re2c::AltOp::calc_size ( ) const
virtual

Implements re2c::RegExp.

Definition at line 14 of file calc_size.cc.

15 {
16  return exp1->calc_size()
17  + exp2->calc_size()
18  + 1;
19 }
virtual uint32_t calc_size() const =0

Here is the call graph for this function:

nfa_state_t * re2c::AltOp::compile ( nfa_t nfa,
nfa_state_t n 
)
virtual

Implements re2c::RegExp.

Definition at line 24 of file nfa.cc.

25 {
26  nfa_state_t *s = &nfa.states[nfa.size++];
27  s->alt(exp1->compile(nfa, t),
28  exp2->compile(nfa, t));
29  return s;
30 }
virtual nfa_state_t * compile(nfa_t &nfa, nfa_state_t *n)=0

Here is the call graph for this function:

void re2c::AltOp::display ( std::ostream &  o) const
virtual

Implements re2c::RegExp.

Definition at line 20 of file display.cc.

21 {
22  o << exp1 << "|" << exp2;
23 }
uint32_t re2c::AltOp::fixedLength ( )
virtual

Reimplemented from re2c::RegExp.

Definition at line 17 of file fixed_length.cc.

18 {
19  uint32_t l1 = exp1->fixedLength ();
20  uint32_t l2 = exp1->fixedLength ();
21 
22  if (l1 != l2 || l1 == ~0u)
23  {
24  return ~0u;
25  }
26 
27  return l1;
28 }
virtual uint32_t fixedLength()
Definition: fixed_length.cc:12

Here is the call graph for this function:

re2c::AltOp::FORBID_COPY ( AltOp  )
void re2c::AltOp::split ( std::set< uint32_t > &  cs)
virtual

Implements re2c::RegExp.

Definition at line 15 of file split.cc.

16 {
17  exp1->split (cs);
18  exp2->split (cs);
19 }
virtual void split(std::set< uint32_t > &)=0

Here is the call graph for this function:

Friends And Related Function Documentation

RegExp* mkAlt ( RegExp ,
RegExp  
)
friend

Definition at line 40 of file regexp.cc.

41 {
42  AltOp * a;
43  MatchOp * m1;
44  MatchOp * m2;
45 
46  a = dynamic_cast<AltOp*> (e1);
47  if (a != NULL)
48  {
49  m1 = dynamic_cast<MatchOp*> (a->exp1);
50  if (m1 != NULL)
51  {
52  e1 = a->exp2;
53  }
54  }
55  else
56  {
57  m1 = dynamic_cast<MatchOp*> (e1);
58  if (m1 != NULL)
59  {
60  e1 = NULL;
61  }
62  }
63  a = dynamic_cast<AltOp*> (e2);
64  if (a != NULL)
65  {
66  m2 = dynamic_cast<MatchOp*> (a->exp1);
67  if (m2 != NULL)
68  {
69  e2 = a->exp2;
70  }
71  }
72  else
73  {
74  m2 = dynamic_cast<MatchOp*> (e2);
75  if (m2 != NULL)
76  {
77  e2 = NULL;
78  }
79  }
80 
81  return doAlt (merge (m1, m2), doAlt (e1, e2));
82 }
RegExp * doAlt(RegExp *e1, RegExp *e2)
Definition: regexp.cc:27
static uint32_t merge(Span *x0, State *fg, State *bg)
Definition: prepare.cc:31
AltOp(RegExp *e1, RegExp *e2)
Definition: regexp_alt.h:15

The documentation for this class was generated from the following files: