source: src/dgp/grammar.hh @ 5f4d9c3

Last change on this file since 5f4d9c3 was 5f4d9c3, checked in by Maciej Prill <mprill@…>, 12 years ago

Rewritten the build system, added lem UTF-8 version.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1#ifndef _GRAMMAR_HH
2#define _GRAMMAR_HH
3
4#include <bitset>
5#include <vector>
6#include <list>
7#include <set>
8
9#include "const.hh"
10#include "thesymbols.hh"
11#include "sgraph.hh"
12
13
14class Link
15{
16  Role role;
17  FlagSet hflags;
18  FlagSet dflags;
19};
20
21
22class Grammar
23{
24
25 public:
26
27  //  enum CONSTR { SGL, OBL, LEFT, RIGHT, INIT, NONINIT, FIN, NONFIN };
28
29  Grammar() : types_sz(0), cats_sz(0), flags_sz(0) {} ;
30 
31  int types_sz;
32  int cats_sz;
33  int flags_sz;
34
35  vector< vector< Roles > >    connect;
36  RoleSet                      sgl;
37  vector< RoleSet >            obl;
38  RoleSet                      left;
39  RoleSet                      right;
40  vector< RoleSet >            lt;
41  vector< RoleSet >            gt;
42
43
44  //  vector< vector< vector<
45  vector< FlagSet >            set;
46  vector< FlagSet >            pass;
47
48  bool read(FILE* f);
49  void write(FILE* f);
50
51  void add_category(const char* s);
52  void add_type(const char* s);
53  void add_flag(const char* s);
54
55  void set_sgl(Role r)           { sgl.set(r); }
56  void set_obl(Cat c, Role r)    { obl[c].set(r); }
57  void set_left(Role r)          { left.set(r); }
58  void set_right(Role r)         { right.set(r); }
59  void set_order(Role r, Role s) { lt[s].set(r); }
60  void set_connect(Cat c, Cat d, Role r)   { connect[c][d].insert(r); }
61  void set_lt(Role r, Role s);
62  void compute_gt();
63
64
65  bool check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role);
66
67};
68
69inline bool Grammar::check_constr(NodeProp& hprop, NodeProp& dprop, int dir, Role role)
70{
71  return 
72    !hprop.forbidden[role] &&
73    ( !right[role] || dir==1 ) &&
74    ( !left[role] || dir==0 )
75    ;
76}
77
78
79#endif
Note: See TracBrowser for help on using the repository browser.