ruco-cpp 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +17 -0
- data/bin/console +14 -0
- data/bin/ruco +30 -0
- data/bin/setup +7 -0
- data/data/ruco/Parser.frame +359 -0
- data/data/ruco/Scanner.frame +896 -0
- data/data/ruco/picojson/Changes +14 -0
- data/data/ruco/picojson/LICENSE +25 -0
- data/data/ruco/picojson/Makefile +8 -0
- data/data/ruco/picojson/README.mkdn +183 -0
- data/data/ruco/picojson/examples/github-issues.cc +110 -0
- data/data/ruco/picojson/examples/iostream.cc +70 -0
- data/data/ruco/picojson/examples/streaming.cc +76 -0
- data/data/ruco/picojson/picojson.h +1299 -0
- data/ext/cocor/Action.cpp +81 -0
- data/ext/cocor/Action.h +59 -0
- data/ext/cocor/ArrayList.cpp +79 -0
- data/ext/cocor/ArrayList.h +52 -0
- data/ext/cocor/BitArray.cpp +156 -0
- data/ext/cocor/BitArray.h +68 -0
- data/ext/cocor/CharClass.cpp +42 -0
- data/ext/cocor/CharClass.h +48 -0
- data/ext/cocor/CharSet.cpp +166 -0
- data/ext/cocor/CharSet.h +68 -0
- data/ext/cocor/Coco.atg +528 -0
- data/ext/cocor/Coco.cpp +173 -0
- data/ext/cocor/Comment.cpp +45 -0
- data/ext/cocor/Comment.h +51 -0
- data/ext/cocor/Copyright.frame +27 -0
- data/ext/cocor/DFA.cpp +865 -0
- data/ext/cocor/DFA.h +132 -0
- data/ext/cocor/Generator.cpp +182 -0
- data/ext/cocor/Generator.h +61 -0
- data/ext/cocor/Graph.h +59 -0
- data/ext/cocor/HashTable.cpp +115 -0
- data/ext/cocor/HashTable.h +84 -0
- data/ext/cocor/Makefile +11 -0
- data/ext/cocor/Melted.cpp +39 -0
- data/ext/cocor/Melted.h +51 -0
- data/ext/cocor/Node.cpp +69 -0
- data/ext/cocor/Node.h +86 -0
- data/ext/cocor/Parser.cpp +925 -0
- data/ext/cocor/Parser.frame +326 -0
- data/ext/cocor/Parser.h +153 -0
- data/ext/cocor/ParserGen.cpp +486 -0
- data/ext/cocor/ParserGen.h +99 -0
- data/ext/cocor/Position.cpp +37 -0
- data/ext/cocor/Position.h +46 -0
- data/ext/cocor/README.md +12 -0
- data/ext/cocor/Scanner.cpp +833 -0
- data/ext/cocor/Scanner.frame +897 -0
- data/ext/cocor/Scanner.h +291 -0
- data/ext/cocor/Sets.h +84 -0
- data/ext/cocor/SortedList.cpp +141 -0
- data/ext/cocor/SortedList.h +68 -0
- data/ext/cocor/State.cpp +77 -0
- data/ext/cocor/State.h +55 -0
- data/ext/cocor/StringBuilder.cpp +88 -0
- data/ext/cocor/StringBuilder.h +29 -0
- data/ext/cocor/Symbol.cpp +61 -0
- data/ext/cocor/Symbol.h +70 -0
- data/ext/cocor/Tab.cpp +1248 -0
- data/ext/cocor/Tab.h +245 -0
- data/ext/cocor/Target.cpp +41 -0
- data/ext/cocor/Target.h +48 -0
- data/ext/cocor/build.bat +3 -0
- data/ext/cocor/build.sh +4 -0
- data/ext/cocor/coc.bat +1 -0
- data/ext/cocor/coc.sh +2 -0
- data/ext/cocor/cocor_ruby_ext.cpp +124 -0
- data/ext/cocor/cygBuild.bat +1 -0
- data/ext/cocor/extconf.rb +5 -0
- data/ext/cocor/mingwbuild.bat +2 -0
- data/ext/cocor/mkmf.log +57 -0
- data/ext/cocor/zipsources.bat +1 -0
- data/lib/cocor.rb +14 -0
- data/lib/ruco/version.rb +3 -0
- data/lib/ruco.rb +728 -0
- metadata +195 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#include "Action.h"
|
30
|
+
#include "Target.h"
|
31
|
+
#include "CharSet.h"
|
32
|
+
|
33
|
+
namespace Coco {
|
34
|
+
|
35
|
+
Action::Action(int typ, int sym, int tc) {
|
36
|
+
this->target = NULL;
|
37
|
+
this->next = NULL;
|
38
|
+
|
39
|
+
this->typ = typ; this->sym = sym; this->tc = tc;
|
40
|
+
}
|
41
|
+
|
42
|
+
void Action::AddTarget(Target *t) { // add t to the action.targets
|
43
|
+
Target *last = NULL;
|
44
|
+
Target *p = target;
|
45
|
+
while (p != NULL && t->state->nr >= p->state->nr) {
|
46
|
+
if (t->state == p->state) return;
|
47
|
+
last = p; p = p->next;
|
48
|
+
}
|
49
|
+
t->next = p;
|
50
|
+
if (p == target) target = t; else last->next = t;
|
51
|
+
}
|
52
|
+
|
53
|
+
void Action::AddTargets(Action *a) {// add copy of a.targets to action.targets
|
54
|
+
for (Target *p = a->target; p != NULL; p = p->next) {
|
55
|
+
Target *t = new Target(p->state);
|
56
|
+
AddTarget(t);
|
57
|
+
}
|
58
|
+
if (a->tc == Node::contextTrans) tc = Node::contextTrans;
|
59
|
+
}
|
60
|
+
|
61
|
+
CharSet* Action::Symbols(Tab *tab) {
|
62
|
+
CharSet *s;
|
63
|
+
if (typ == Node::clas)
|
64
|
+
s = tab->CharClassSet(sym)->Clone();
|
65
|
+
else {
|
66
|
+
s = new CharSet(); s->Set(sym);
|
67
|
+
}
|
68
|
+
return s;
|
69
|
+
}
|
70
|
+
|
71
|
+
void Action::ShiftWith(CharSet *s, Tab *tab) {
|
72
|
+
if (s->Elements() == 1) {
|
73
|
+
typ = Node::chr; sym = s->First();
|
74
|
+
} else {
|
75
|
+
CharClass *c = tab->FindCharClass(s);
|
76
|
+
if (c == NULL) c = tab->NewCharClass(L"#", s); // class with dummy name
|
77
|
+
typ = Node::clas; sym = c->n;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
}; // namespace
|
data/ext/cocor/Action.h
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#if !defined(COCO_ACTION_H__)
|
30
|
+
#define COCO_ACTION_H__
|
31
|
+
|
32
|
+
#include "State.h"
|
33
|
+
#include "Tab.h"
|
34
|
+
|
35
|
+
namespace Coco {
|
36
|
+
|
37
|
+
class Target;
|
38
|
+
class CharSet;
|
39
|
+
|
40
|
+
class Action // action of finite automaton
|
41
|
+
{
|
42
|
+
public:
|
43
|
+
int typ; // type of action symbol: clas, chr
|
44
|
+
int sym; // action symbol
|
45
|
+
int tc; // transition code: normalTrans, contextTrans
|
46
|
+
Target *target; // states reached from this action
|
47
|
+
Action *next;
|
48
|
+
|
49
|
+
Action(int typ, int sym, int tc);
|
50
|
+
void AddTarget(Target *t); // add t to the action.targets
|
51
|
+
void AddTargets(Action *a); // add copy of a.targets to action.targets
|
52
|
+
CharSet* Symbols(Tab *tab);
|
53
|
+
void ShiftWith(CharSet *s, Tab *tab);
|
54
|
+
};
|
55
|
+
|
56
|
+
}; // namespace
|
57
|
+
|
58
|
+
|
59
|
+
#endif // !defined(COCO_ACTION_H__)
|
@@ -0,0 +1,79 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#include <stdio.h>
|
30
|
+
#include "ArrayList.h"
|
31
|
+
|
32
|
+
namespace Coco {
|
33
|
+
|
34
|
+
ArrayList::ArrayList() {
|
35
|
+
Count = 0;
|
36
|
+
Capacity = 10;
|
37
|
+
Data = new void*[ Capacity ];
|
38
|
+
}
|
39
|
+
|
40
|
+
ArrayList::~ArrayList() {
|
41
|
+
delete [] Data;
|
42
|
+
}
|
43
|
+
|
44
|
+
void ArrayList::Add(void *value) {
|
45
|
+
if (Count < Capacity) {
|
46
|
+
Data[Count] = value;
|
47
|
+
Count++;
|
48
|
+
} else {
|
49
|
+
Capacity *= 2;
|
50
|
+
void** newData = new void*[Capacity];
|
51
|
+
for (int i=0; i<Count; i++) {
|
52
|
+
newData[i] = Data[i]; // copy
|
53
|
+
}
|
54
|
+
newData[Count] = value;
|
55
|
+
Count++;
|
56
|
+
delete [] Data;
|
57
|
+
Data = newData;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
void ArrayList::Remove(void *value) {
|
62
|
+
for (int i=0; i<Count; i++) {
|
63
|
+
if (Data[i] == value) {
|
64
|
+
for (int j=i+1; j<Count; j++)
|
65
|
+
Data[j-1] = Data[j];
|
66
|
+
Count--;
|
67
|
+
break;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
void* ArrayList::operator[]( int index )
|
73
|
+
{
|
74
|
+
if (0<=index && index<Count)
|
75
|
+
return Data[index];
|
76
|
+
return NULL;
|
77
|
+
}
|
78
|
+
|
79
|
+
}; // namespace
|
@@ -0,0 +1,52 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#if !defined(COCO_ARRAYLIST_H__)
|
30
|
+
#define COCO_ARRAYLIST_H__
|
31
|
+
|
32
|
+
namespace Coco {
|
33
|
+
|
34
|
+
class ArrayList
|
35
|
+
{
|
36
|
+
public:
|
37
|
+
ArrayList();
|
38
|
+
virtual ~ArrayList();
|
39
|
+
|
40
|
+
void Add(void *value);
|
41
|
+
void Remove(void *value);
|
42
|
+
void* operator[](int index);
|
43
|
+
|
44
|
+
int Count;
|
45
|
+
int Capacity;
|
46
|
+
private:
|
47
|
+
void** Data;
|
48
|
+
};
|
49
|
+
|
50
|
+
}; // namespace
|
51
|
+
|
52
|
+
#endif // !defined(COCO_ARRAYLIST_H__)
|
@@ -0,0 +1,156 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#include <memory.h>
|
30
|
+
#include <stdio.h>
|
31
|
+
#include "BitArray.h"
|
32
|
+
|
33
|
+
namespace Coco {
|
34
|
+
|
35
|
+
BitArray::BitArray(const int length, const bool defaultValue)
|
36
|
+
{
|
37
|
+
Count = length;
|
38
|
+
Data = new unsigned char[ (length+7)>>3 ];
|
39
|
+
if (defaultValue)
|
40
|
+
memset(Data, 0xFF, (length+7)>>3);
|
41
|
+
else
|
42
|
+
memset(Data, 0x00, (length+7)>>3);
|
43
|
+
}
|
44
|
+
|
45
|
+
BitArray::BitArray(const BitArray ©) {
|
46
|
+
Count = copy.Count;
|
47
|
+
Data = new unsigned char[ (copy.Count+7)>>3 ];
|
48
|
+
memcpy(Data, copy.Data, (copy.Count+7)>>3);
|
49
|
+
}
|
50
|
+
|
51
|
+
BitArray::~BitArray()
|
52
|
+
{
|
53
|
+
delete [] Data;
|
54
|
+
Data = NULL;
|
55
|
+
}
|
56
|
+
|
57
|
+
int BitArray::getCount() {
|
58
|
+
return Count;
|
59
|
+
}
|
60
|
+
|
61
|
+
bool BitArray::Get(const int index) const
|
62
|
+
{
|
63
|
+
return (Data[(index>>3)] & (1<<(index&7))) != 0;
|
64
|
+
}
|
65
|
+
|
66
|
+
void BitArray::Set(const int index, const bool value)
|
67
|
+
{
|
68
|
+
if (value){
|
69
|
+
Data[(index>>3)] |= (1 << (index&7));
|
70
|
+
} else {
|
71
|
+
unsigned char mask = 0xFF;
|
72
|
+
mask ^= (1 << (index&7));
|
73
|
+
Data[(index>>3)] &= mask;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
void BitArray::SetAll(const bool value)
|
78
|
+
{
|
79
|
+
if (value)
|
80
|
+
memset(Data, 0xFF, (Count+7)>>3);
|
81
|
+
else
|
82
|
+
memset(Data, 0x00, (Count+7)>>3);
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
void BitArray::Not()
|
87
|
+
{
|
88
|
+
for (int i=0; i<(Count+7)>>3; i++) {
|
89
|
+
Data[i] ^= 0xFF;
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
void BitArray::And(const BitArray *value)
|
94
|
+
{
|
95
|
+
for (int i=0; (i<(Count+7)>>3) && (i<(value->Count+7)>>3); i++) {
|
96
|
+
Data[i] = (Data[i] & value->Data[i]);
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
void BitArray::Or(const BitArray *value)
|
101
|
+
{
|
102
|
+
for (int i=0; (i<(Count+7)>>3) && (i<(value->Count+7)>>3); i++) {
|
103
|
+
Data[i] = (Data[i] | value->Data[i]);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
void BitArray::Xor(const BitArray *value)
|
108
|
+
{
|
109
|
+
for (int i=0; (i<(Count+7)>>3) && (i<(value->Count+7)>>3); i++) {
|
110
|
+
Data[i] = (Data[i] ^ value->Data[i]);
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
BitArray* BitArray::Clone() const
|
115
|
+
{
|
116
|
+
BitArray *newBitArray = new BitArray(Count);
|
117
|
+
newBitArray->Count = Count;
|
118
|
+
memcpy(newBitArray->Data, Data, (Count+7)>>3);
|
119
|
+
return newBitArray;
|
120
|
+
}
|
121
|
+
|
122
|
+
bool BitArray::Equal(const BitArray *right) const
|
123
|
+
{
|
124
|
+
if (Count != right->Count) {
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
for(int index = 0; index < Count; index++) {
|
128
|
+
if (Get(index) != right->Get(index)) {
|
129
|
+
return false;
|
130
|
+
}
|
131
|
+
}
|
132
|
+
return true;
|
133
|
+
}
|
134
|
+
|
135
|
+
bool BitArray::Overlaps(const BitArray *right) const
|
136
|
+
{
|
137
|
+
for (int index = 0; index < Count; ++index) {
|
138
|
+
if (Get(index) && right->Get(index)) {
|
139
|
+
return true;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
return false;
|
143
|
+
}
|
144
|
+
|
145
|
+
const BitArray &BitArray::operator=(const BitArray &right)
|
146
|
+
{
|
147
|
+
if ( &right != this ) { // avoid self assignment
|
148
|
+
delete [] Data; // prevents memory leak
|
149
|
+
Count = right.Count;
|
150
|
+
Data = new unsigned char[ (Count+7)>>3 ];
|
151
|
+
memcpy(Data, right.Data, (Count+7)>>3);
|
152
|
+
}
|
153
|
+
return *this; // enables cascaded assignments
|
154
|
+
}
|
155
|
+
|
156
|
+
} // namespace
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#if !defined(COCO_BITARRAY_H__)
|
30
|
+
#define COCO_BITARRAY_H__
|
31
|
+
|
32
|
+
namespace Coco {
|
33
|
+
|
34
|
+
class BitArray
|
35
|
+
{
|
36
|
+
public:
|
37
|
+
BitArray(int length = 0, bool defaultValue = false) ;
|
38
|
+
BitArray(const BitArray © );
|
39
|
+
virtual ~BitArray();
|
40
|
+
|
41
|
+
int getCount();
|
42
|
+
|
43
|
+
bool Get(const int index) const;
|
44
|
+
void Set(const int index, const bool value);
|
45
|
+
void SetAll(const bool value);
|
46
|
+
bool Equal(const BitArray *right ) const;
|
47
|
+
bool Overlaps(const BitArray *right ) const;
|
48
|
+
bool operator[](const int index) const { return Get(index); };
|
49
|
+
|
50
|
+
const BitArray &operator=(const BitArray &right);
|
51
|
+
|
52
|
+
void Not();
|
53
|
+
void And(const BitArray *value);
|
54
|
+
void Or(const BitArray *value);
|
55
|
+
void Xor(const BitArray *value);
|
56
|
+
|
57
|
+
BitArray* Clone() const;
|
58
|
+
|
59
|
+
private:
|
60
|
+
int Count;
|
61
|
+
unsigned char* Data;
|
62
|
+
void setMem(int length, bool value);
|
63
|
+
|
64
|
+
};
|
65
|
+
|
66
|
+
}
|
67
|
+
|
68
|
+
#endif // !defined(COCO_BITARRAY_H__)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#include "CharClass.h"
|
30
|
+
#include "Scanner.h"
|
31
|
+
|
32
|
+
namespace Coco {
|
33
|
+
|
34
|
+
CharClass::CharClass(const wchar_t* name, CharSet *s) {
|
35
|
+
this->name = coco_string_create(name); this->set = s;
|
36
|
+
}
|
37
|
+
|
38
|
+
CharClass::~CharClass() {
|
39
|
+
coco_string_delete(name);
|
40
|
+
}
|
41
|
+
|
42
|
+
}; // namespace
|
@@ -0,0 +1,48 @@
|
|
1
|
+
/*-------------------------------------------------------------------------
|
2
|
+
Compiler Generator Coco/R,
|
3
|
+
Copyright (c) 1990, 2004 Hanspeter Moessenboeck, University of Linz
|
4
|
+
extended by M. Loeberbauer & A. Woess, Univ. of Linz
|
5
|
+
ported to C++ by Csaba Balazs, University of Szeged
|
6
|
+
with improvements by Pat Terry, Rhodes University
|
7
|
+
|
8
|
+
This program is free software; you can redistribute it and/or modify it
|
9
|
+
under the terms of the GNU General Public License as published by the
|
10
|
+
Free Software Foundation; either version 2, or (at your option) any
|
11
|
+
later version.
|
12
|
+
|
13
|
+
This program is distributed in the hope that it will be useful, but
|
14
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15
|
+
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16
|
+
for more details.
|
17
|
+
|
18
|
+
You should have received a copy of the GNU General Public License along
|
19
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
20
|
+
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
21
|
+
|
22
|
+
As an exception, it is allowed to write an extension of Coco/R that is
|
23
|
+
used as a plugin in non-free software.
|
24
|
+
|
25
|
+
If not otherwise stated, any source code generated by Coco/R (other than
|
26
|
+
Coco/R itself) does not fall under the GNU General Public License.
|
27
|
+
-------------------------------------------------------------------------*/
|
28
|
+
|
29
|
+
#if !defined(COCO_CHARCLASS_H__)
|
30
|
+
#define COCO_CHARCLASS_H__
|
31
|
+
|
32
|
+
#include "CharSet.h"
|
33
|
+
|
34
|
+
namespace Coco {
|
35
|
+
|
36
|
+
class CharClass {
|
37
|
+
public:
|
38
|
+
int n; // class number
|
39
|
+
wchar_t* name; // class name
|
40
|
+
CharSet *set; // set representing the class
|
41
|
+
|
42
|
+
CharClass(const wchar_t* name, CharSet *s);
|
43
|
+
virtual ~CharClass();
|
44
|
+
};
|
45
|
+
|
46
|
+
}; // namespace
|
47
|
+
|
48
|
+
#endif // !defined(COCO_CHARCLASS_H__)
|