source: _old/app/src/lib/ttrans.h @ 8f395c8

Last change on this file since 8f395c8 was a6e708f, checked in by tom <tom@…>, 13 years ago

ANULOWANIE POPRZEDNIEGO COMMITU

Revert "Replacing old implementation with working implementation"

This reverts commit 1e121f45e2d091fcd34a893291b8453e350d5884.

Please enter the commit message for your changes. Lines starting
with '#' will be ignored, and an empty message aborts the commit.

Committer: tom <tom@lim.(none)>

On branch master
Changes to be committed:

(use "git reset HEAD <file>..." to unstage)

modified: _old/app/Makefile
deleted: _old/app/conf/Makefile
deleted: _old/app/conf/compiledic.conf
deleted: _old/app/conf/cor.conf
deleted: _old/app/conf/dgc.conf
deleted: _old/app/conf/dgp.conf
deleted: _old/app/conf/gph.conf
deleted: _old/app/conf/grp.conf
deleted: _old/app/conf/gue.conf
deleted: _old/app/conf/kor.conf
deleted: _old/app/conf/lem.conf
deleted: _old/app/conf/mar.conf
deleted: _old/app/conf/ser.conf
deleted: _old/app/conf/utt.conf
modified: _old/app/src/common/Makefile
modified: _old/app/src/compiledic/Makefile
modified: _old/app/src/compiledic/aut2fsa.cc
modified: _old/app/src/cor/Makefile
modified: _old/app/src/dgp/Makefile
new file: _old/app/src/dgp/canonize
new file: _old/app/src/dgp/dgc
modified: _old/app/src/dgp/grammar.hh
modified: _old/app/src/dgp/mgraph.hh
modified: _old/app/src/dgp/sgraph.hh
modified: _old/app/src/dgp/thesymbols.hh
new file: _old/app/src/dgp/tre
modified: _old/app/src/gue/Makefile
modified: _old/app/src/gue/guess.cc
modified: _old/app/src/kor/Makefile
modified: _old/app/src/kor/corlist.cc
modified: _old/app/src/kor/corr.cc
new file: _old/app/src/kor/corr.hh
modified: _old/app/src/kor/main.cc
modified: _old/app/src/lem/Makefile
modified: _old/app/src/lem/lem.cc
modified: _old/app/src/lib/Makefile
modified: _old/app/src/lib/auttools.cc
modified: _old/app/src/lib/symtab.cc
modified: _old/app/src/lib/tft.h
modified: _old/app/src/lib/tfti.h
modified: _old/app/src/lib/ttrans.h
modified: _old/app/src/lib/word.cc
modified: _old/app/src/lib/word.h
modified: _old/app/src/tok.c/Makefile
modified: _old/app/src/tok.c/cmdline_tok.ggo
modified: _old/app/src/tok.c/common_tok.cc
modified: _old/app/src/tok/Makefile
modified: _old/nawszelkiwypadek/tools/aut2fsa
modified: _old/nawszelkiwypadek/tools/cor_dic/makeLabels.pl
modified: _old/nawszelkiwypadek/tools/cor_dic/prep.pl
modified: _old/nawszelkiwypadek/tools/fsm2aut
modified: _old/nawszelkiwypadek/tools/gue_dic/canon.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/compile_user_dict.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/count_prefs.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/cut_prefs.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/makeLabels.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/prep.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/prep_user_dict.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/rmDup.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/stat.pl
modified: _old/nawszelkiwypadek/tools/gue_dic/stat_pre.pl
modified: _old/nawszelkiwypadek/tools/lem_dic/makeLabels.pl
modified: _old/nawszelkiwypadek/tools/lem_dic/prep.pl
modified: auto/defaults
modified: auto/options
modified: auto/output/Makefile
modified: auto/output/config_h
modified: auto/summary
modified: configure

  • Property mode set to 100755
File size: 5.4 KB
Line 
1#ifndef _TTransi_h
2#define _TTransi_h
3//---------------------------------------------------------------------------
4#include <iostream>
5//---------------------------------------------------------------------------
6
7
8using namespace std;
9
10//! The template for a transition with input and output symbols stored internally.
11/*!
12    A state is identified with the set of its outgoing transitions.
13    The state index is the index of the first transition for it.
14    A state with no outgoing transition is represented as an empty transition.
15*/
16template<class I, class Ipass, class O, class Opass>
17class TTrans_i
18{
19public:
20//private:
21//! Input symbol
22  I i;
23//! Output symbol
24  O o;
25
26public:
27
28//! state is final
29  static const unsigned char BITf=0x01;
30//! transition list is continued
31  static const unsigned char BITc=0x02;
32//! no transition
33  static const unsigned char BITe=0x04;
34//! epsilon input
35  static const unsigned char BITepsi=0x08;
36//! default input
37  static const unsigned char BITdefi=0x10;
38//! epsilon output
39  static const unsigned char BITepso=0x20;
40//! default output
41  static const unsigned char BITdefo=0x40;
42
43//! Flags
44  unsigned char flags;
45
46//! The index of the next state
47  long nxt;
48
49//! Input symbol.
50//! \return The input symbol of the transition.
51  Ipass in() const { return i; }
52
53//! Output symbol.
54//! \return The output symbol of the transition.
55  Opass out() const { return o; }
56
57//! Set the input symbol.
58//! \param in input symbol
59  void in(Ipass in) { i=in; }
60
61//! Set the output symbol.
62//! \param out output symbol
63  void out(Opass out) { o=out; }
64
65//! remark Is this needed?
66  I& iref() { return i; }
67
68//! remark Is this needed?
69  O& oref() { return o; }
70
71//! Test whether an input symbol is accepted.
72//! \remark Simplified. Should rely on a test function provided by the user.
73  bool accepts(Ipass in) { return defi() || in==i; }
74
75//! Next state.
76//! \return Destination state of the transition.
77  long next() const { return nxt; };
78
79//! Set the next state.
80//! \param t destination state of the transition
81  void next(long t) { nxt=t; };
82
83//! Is the state final?
84//! \return \c true if the state is final, false otherwise.
85  bool final() const { return flags&BITf; };
86
87//! Set the \b final flag.
88//! \param b \c true if the state is final, \c false otherwise.
89  void final(bool b) { if(b) flags|=BITf; else flags&=~BITf; };
90
91//! Is the transition list continued?
92//! \return \c true if the transition is not the last transition for the state,
93//! \c false otherwise.
94  bool continued() const { return flags&BITc; };
95
96//! Set the \b continuation flag.
97//! \param b \c true if the transition is not the last one for the state, \c false otherwise.
98  void continued(bool b) { if(b) flags|=BITc; else flags&=~BITc; };
99
100//! Is the transition empty?
101//! \return \c true if the transition is empty (represents a state with no outgoing transitions),
102//! \c false otherwise.
103  bool empty() const { return flags&BITe; };
104
105//! Set the \b empty flag.
106//! \param b \c true if the transition is empty, \c false otherwise.
107  void empty(bool b) { if(b) flags|=BITe; else flags&=~BITe; };
108
109  bool epsi() const { return flags&BITepsi; };
110  void epsi(bool b) { if(b) flags|=BITepsi; else flags&=~BITepsi; };
111
112  bool defi() const { return flags&BITdefi; };
113  void defi(bool b) { if(b) flags|=BITdefi; else flags&=~BITdefi; };
114
115  bool epso() const { return flags&BITepso; };
116  void epso(bool b) { if(b) flags|=BITepso; else flags&=~BITepso; };
117
118  bool defo() const { return flags&BITdefo; };
119  void defo(bool b) { if(b) flags|=BITdefo; else flags&=~BITdefo; };
120
121  void geti(istream&);
122  void geto(istream&);
123
124//  friend ostream& operator<<(ostream& os, const TTrans_i<I,Ipass,O,Opass>& t);
125
126};
127
128//---------------------------------------------------------------------------
129
130template<char>
131void getsym(istream& is, char& c)
132{
133  is >> c;
134  if(c=='\\')
135    {
136      is.get(c);
137      switch(c)
138      {
139        case 'n':c='\n';break;
140        case 't':c='\t';break;
141      }
142    }
143}
144
145template<class T>
146void getsym(istream& is, T& s)
147{ is >> s; }
148
149//---------------------------------------------------------------------------
150
151template<class I, class Ipass, class O, class Opass>
152void TTrans_i<I,Ipass,O,Opass>::geti(istream& is)
153{ getsym<I>(is,iref()); };
154
155template<class I, class Ipass, class O, class Opass>
156void TTrans_i<I,Ipass,O,Opass>::geto(istream& is)
157{ getsym<I>(is,oref()); };
158
159//---------------------------------------------------------------------------
160/*
161template<class I, class Ipass, class O, class Opass>
162ostream& operator<<(ostream& os, const TTrans_i<I,Ipass,O,Opass>& t)
163{
164  os << (t.final() ? '+' : '-');
165  os << ' ';
166
167  if(!t.empty())
168  {
169    if(t.defi())
170      os << (t.epsi() ? '~' : '@');
171    else
172      switch(t.in())
173      {
174        case ' ': os << "\\ "; break;
175        case '\n': os << "\\n"; break;
176        case '\t': os << "\\t"; break;
177        default:   os << t.in();
178      }
179
180    os << '/';
181
182    if(t.defo())
183      os << (t.epso() ? '~' : '@');
184    else
185      switch(t.out())
186      {
187        case ' ': os << "\\ "; break;
188        case '\n': os << "\\n"; break;
189        case '\t': os << "\\t"; break;
190        default:   os << t.out();
191      }
192
193    os << ' ' << t.next();
194  }
195
196  os << '\n';
197
198  if(!t.continued())
199    os << '\n';
200
201  return os;
202}
203*/
204
205//---------------------------------------------------------------------------
206#endif
207
Note: See TracBrowser for help on using the repository browser.