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
data/ext/cocor/State.h
ADDED
@@ -0,0 +1,55 @@
|
|
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_STATE_H__)
|
30
|
+
#define COCO_STATE_H__
|
31
|
+
|
32
|
+
#include "Symbol.h"
|
33
|
+
|
34
|
+
namespace Coco {
|
35
|
+
|
36
|
+
class Action;
|
37
|
+
|
38
|
+
class State // state of finite automaton
|
39
|
+
{
|
40
|
+
public:
|
41
|
+
int nr; // state number
|
42
|
+
Action *firstAction; // to first action of this state
|
43
|
+
Symbol *endOf; // recognized token if state is final
|
44
|
+
bool ctx; // true if state is reached via contextTrans
|
45
|
+
State *next;
|
46
|
+
|
47
|
+
State();
|
48
|
+
void AddAction(Action *act);
|
49
|
+
void DetachAction(Action *act);
|
50
|
+
void MeltWith(State *s);
|
51
|
+
};
|
52
|
+
|
53
|
+
}; // namespace
|
54
|
+
|
55
|
+
#endif // !defined(COCO_STATE_H__)
|
@@ -0,0 +1,88 @@
|
|
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 <string.h>
|
30
|
+
#include "StringBuilder.h"
|
31
|
+
#include "Scanner.h"
|
32
|
+
|
33
|
+
namespace Coco {
|
34
|
+
|
35
|
+
void StringBuilder::Init(int capacity) {
|
36
|
+
length = 0;
|
37
|
+
this->capacity = capacity;
|
38
|
+
data = new wchar_t[capacity + 1];
|
39
|
+
data[0] = 0;
|
40
|
+
}
|
41
|
+
|
42
|
+
StringBuilder::StringBuilder(int capacity) {
|
43
|
+
Init(capacity);
|
44
|
+
}
|
45
|
+
|
46
|
+
StringBuilder::StringBuilder(const wchar_t *val) {
|
47
|
+
capacity = length = wcslen(val);
|
48
|
+
Init(capacity);
|
49
|
+
wcscpy(data, val);
|
50
|
+
}
|
51
|
+
|
52
|
+
StringBuilder::~StringBuilder() {
|
53
|
+
if (data != NULL) {
|
54
|
+
delete [] data;
|
55
|
+
data = NULL;
|
56
|
+
length = 0;
|
57
|
+
capacity = 0;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
void StringBuilder::Append(const wchar_t value) {
|
62
|
+
if (length == capacity) {
|
63
|
+
int oldCap = capacity;
|
64
|
+
capacity = capacity * 2;
|
65
|
+
wchar_t *nData = new wchar_t[capacity + 1];
|
66
|
+
memcpy(nData, data, oldCap * sizeof(int));
|
67
|
+
delete [] data;
|
68
|
+
data = nData;
|
69
|
+
}
|
70
|
+
|
71
|
+
data[length] = value;
|
72
|
+
length++;
|
73
|
+
data[length] = '\0';
|
74
|
+
}
|
75
|
+
|
76
|
+
void StringBuilder::Append(const wchar_t *value) {
|
77
|
+
if (length + (int)wcslen(value) < capacity) {
|
78
|
+
wcscpy(data + length, value);
|
79
|
+
length += wcslen(value);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
wchar_t* StringBuilder::ToString() {
|
85
|
+
return coco_string_create(data);
|
86
|
+
}
|
87
|
+
|
88
|
+
}; // namespace
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#if !defined(COCO_STRINGBUILDER_H__)
|
2
|
+
#define COCO_STRINGBUILDER_H__
|
3
|
+
|
4
|
+
#include<stddef.h>
|
5
|
+
|
6
|
+
namespace Coco {
|
7
|
+
|
8
|
+
class StringBuilder
|
9
|
+
{
|
10
|
+
public:
|
11
|
+
StringBuilder(int capacity = 32);
|
12
|
+
StringBuilder(const wchar_t *val);
|
13
|
+
|
14
|
+
virtual ~StringBuilder();
|
15
|
+
void Append(const wchar_t val);
|
16
|
+
void Append(const wchar_t *val);
|
17
|
+
wchar_t* ToString();
|
18
|
+
int GetLength() { return length; };
|
19
|
+
|
20
|
+
private:
|
21
|
+
void Init(int capacity);
|
22
|
+
wchar_t *data;
|
23
|
+
int capacity;
|
24
|
+
int length;
|
25
|
+
};
|
26
|
+
|
27
|
+
}; // namespace
|
28
|
+
|
29
|
+
#endif // !defined(COCO_STRINGBUILDER_H__)
|
@@ -0,0 +1,61 @@
|
|
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 "Symbol.h"
|
30
|
+
#include "Scanner.h"
|
31
|
+
|
32
|
+
namespace Coco {
|
33
|
+
|
34
|
+
int Symbol::fixedToken = 0;
|
35
|
+
int Symbol::classToken = 1;
|
36
|
+
int Symbol::litToken = 2;
|
37
|
+
int Symbol::classLitToken = 3;
|
38
|
+
|
39
|
+
|
40
|
+
Symbol::Symbol(int typ, const wchar_t* name, int line) {
|
41
|
+
n = 0;
|
42
|
+
graph = NULL;
|
43
|
+
tokenKind = 0;
|
44
|
+
deletable = false;
|
45
|
+
firstReady = false;
|
46
|
+
first = NULL;
|
47
|
+
follow = NULL;
|
48
|
+
nts = NULL;
|
49
|
+
attrPos = NULL;
|
50
|
+
semPos = NULL;
|
51
|
+
|
52
|
+
this->typ = typ;
|
53
|
+
this->name = coco_string_create(name);
|
54
|
+
this->line = line;
|
55
|
+
}
|
56
|
+
|
57
|
+
Symbol::~Symbol() {
|
58
|
+
coco_string_delete(name);
|
59
|
+
}
|
60
|
+
|
61
|
+
}; // namespace
|
data/ext/cocor/Symbol.h
ADDED
@@ -0,0 +1,70 @@
|
|
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_SYMBOL_H__)
|
30
|
+
#define COCO_SYMBOL_H__
|
31
|
+
|
32
|
+
#include "Position.h"
|
33
|
+
#include "Scanner.h"
|
34
|
+
|
35
|
+
namespace Coco {
|
36
|
+
|
37
|
+
class Node;
|
38
|
+
class BitArray;
|
39
|
+
|
40
|
+
class Symbol {
|
41
|
+
public:
|
42
|
+
// token kinds
|
43
|
+
static int fixedToken; // e.g. 'a' ('b' | 'c') (structure of literals)
|
44
|
+
static int classToken; // e.g. digit {digit} (at least one char class)
|
45
|
+
static int litToken; // e.g. "while"
|
46
|
+
static int classLitToken; // e.g. letter {letter} but without literals that have the same structure*/
|
47
|
+
|
48
|
+
int n; // symbol number
|
49
|
+
int typ; // t, nt, pr, unknown, rslv /* ML 29_11_2002 slv added */ /* AW slv --> rslv */
|
50
|
+
wchar_t *name; // symbol name
|
51
|
+
Node *graph; // nt: to first node of syntax graph
|
52
|
+
int tokenKind; // t: token kind (fixedToken, classToken, ...)
|
53
|
+
bool deletable; // nt: true if nonterminal is deletable
|
54
|
+
bool firstReady; // nt: true if terminal start symbols have already been computed
|
55
|
+
BitArray *first; // nt: terminal start symbols
|
56
|
+
BitArray *follow; // nt: terminal followers
|
57
|
+
BitArray *nts; // nt: nonterminals whose followers have to be added to this sym
|
58
|
+
int line; // source text line number of item in this node
|
59
|
+
Position *attrPos; // nt: position of attributes in source text (or null)
|
60
|
+
Position *semPos; // pr: pos of semantic action in source text (or null)
|
61
|
+
// nt: pos of local declarations in source text (or null)
|
62
|
+
|
63
|
+
|
64
|
+
Symbol(int typ, const wchar_t* name, int line);
|
65
|
+
virtual ~Symbol();
|
66
|
+
};
|
67
|
+
|
68
|
+
}; // namespace
|
69
|
+
|
70
|
+
#endif // !defined(COCO_SYMBOL_H__)
|