fsmedge.h

来自「用于词法分析的词法分析器」· C头文件 代码 · 共 79 行

H
79
字号
/*  $Id: FsmEdge.h,v 1.3 1997/02/02 01:31:02 matt Exp $  FSM edge class.    (c) Feb 1995 Matt Phillips.  */#ifndef _FSM_EDGE_H#define _FSM_EDGE_H#include <util/type.h>#include <util/Range.h>// min and max required for Range<uchar>inline uchar max (uchar c1, const uchar c2){  return c1 > c2 ? c1 : c2;}inline uchar min (uchar c1, const uchar c2){  return c1 < c2 ? c1 : c2;}class FsmState;			// forward decltypedef Range<uchar> UCharRange;class FsmEdge : public UCharRange{  friend class FsmState;  friend ostream &operator << (ostream &os, const FsmEdge &edge);   public:  // normal edge constructors  FsmEdge (UCharRange rng, FsmState &_target) :    UCharRange (rng), target (&_target), epsilon (0) {}  FsmEdge (uchar l, uchar u, FsmState &_target) :    UCharRange (l, u), target (&_target), epsilon (0) {}  FsmEdge (const FsmEdge &e) :    UCharRange (e), target (e.target), epsilon (e.epsilon) {}  // special copy-with-a-different-target constructor!  FsmEdge (FsmState &t, const FsmEdge &e) : UCharRange (e), target (&t),      epsilon (e.epsilon) {}     // epsilon edge constructor  FsmEdge (FsmState &_target) : target (&_target), epsilon (1) {}  void operator = (const FsmEdge &e)  {UCharRange::operator = (e); epsilon = e.epsilon; target = e.target;}  // an epsilon edge is <= any edge  int operator <= (const FsmEdge &e) const;  int operator < (const FsmEdge &e) const;  int isEpsilon () const {return epsilon;}  void makeEpsilon () {epsilon = 1; lower = upper = 0;}  FsmState &getTarget () const {return *target;}protected:  void setTarget (FsmState &state) {target = &state;}  FsmState *target;  int epsilon;};ostream &operator << (ostream &os, const FsmEdge &edge);#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?