ruco-cpp 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +17 -0
  3. data/bin/console +14 -0
  4. data/bin/ruco +30 -0
  5. data/bin/setup +7 -0
  6. data/data/ruco/Parser.frame +359 -0
  7. data/data/ruco/Scanner.frame +896 -0
  8. data/data/ruco/picojson/Changes +14 -0
  9. data/data/ruco/picojson/LICENSE +25 -0
  10. data/data/ruco/picojson/Makefile +8 -0
  11. data/data/ruco/picojson/README.mkdn +183 -0
  12. data/data/ruco/picojson/examples/github-issues.cc +110 -0
  13. data/data/ruco/picojson/examples/iostream.cc +70 -0
  14. data/data/ruco/picojson/examples/streaming.cc +76 -0
  15. data/data/ruco/picojson/picojson.h +1299 -0
  16. data/ext/cocor/Action.cpp +81 -0
  17. data/ext/cocor/Action.h +59 -0
  18. data/ext/cocor/ArrayList.cpp +79 -0
  19. data/ext/cocor/ArrayList.h +52 -0
  20. data/ext/cocor/BitArray.cpp +156 -0
  21. data/ext/cocor/BitArray.h +68 -0
  22. data/ext/cocor/CharClass.cpp +42 -0
  23. data/ext/cocor/CharClass.h +48 -0
  24. data/ext/cocor/CharSet.cpp +166 -0
  25. data/ext/cocor/CharSet.h +68 -0
  26. data/ext/cocor/Coco.atg +528 -0
  27. data/ext/cocor/Coco.cpp +173 -0
  28. data/ext/cocor/Comment.cpp +45 -0
  29. data/ext/cocor/Comment.h +51 -0
  30. data/ext/cocor/Copyright.frame +27 -0
  31. data/ext/cocor/DFA.cpp +865 -0
  32. data/ext/cocor/DFA.h +132 -0
  33. data/ext/cocor/Generator.cpp +182 -0
  34. data/ext/cocor/Generator.h +61 -0
  35. data/ext/cocor/Graph.h +59 -0
  36. data/ext/cocor/HashTable.cpp +115 -0
  37. data/ext/cocor/HashTable.h +84 -0
  38. data/ext/cocor/Makefile +11 -0
  39. data/ext/cocor/Melted.cpp +39 -0
  40. data/ext/cocor/Melted.h +51 -0
  41. data/ext/cocor/Node.cpp +69 -0
  42. data/ext/cocor/Node.h +86 -0
  43. data/ext/cocor/Parser.cpp +925 -0
  44. data/ext/cocor/Parser.frame +326 -0
  45. data/ext/cocor/Parser.h +153 -0
  46. data/ext/cocor/ParserGen.cpp +486 -0
  47. data/ext/cocor/ParserGen.h +99 -0
  48. data/ext/cocor/Position.cpp +37 -0
  49. data/ext/cocor/Position.h +46 -0
  50. data/ext/cocor/README.md +12 -0
  51. data/ext/cocor/Scanner.cpp +833 -0
  52. data/ext/cocor/Scanner.frame +897 -0
  53. data/ext/cocor/Scanner.h +291 -0
  54. data/ext/cocor/Sets.h +84 -0
  55. data/ext/cocor/SortedList.cpp +141 -0
  56. data/ext/cocor/SortedList.h +68 -0
  57. data/ext/cocor/State.cpp +77 -0
  58. data/ext/cocor/State.h +55 -0
  59. data/ext/cocor/StringBuilder.cpp +88 -0
  60. data/ext/cocor/StringBuilder.h +29 -0
  61. data/ext/cocor/Symbol.cpp +61 -0
  62. data/ext/cocor/Symbol.h +70 -0
  63. data/ext/cocor/Tab.cpp +1248 -0
  64. data/ext/cocor/Tab.h +245 -0
  65. data/ext/cocor/Target.cpp +41 -0
  66. data/ext/cocor/Target.h +48 -0
  67. data/ext/cocor/build.bat +3 -0
  68. data/ext/cocor/build.sh +4 -0
  69. data/ext/cocor/coc.bat +1 -0
  70. data/ext/cocor/coc.sh +2 -0
  71. data/ext/cocor/cocor_ruby_ext.cpp +124 -0
  72. data/ext/cocor/cygBuild.bat +1 -0
  73. data/ext/cocor/extconf.rb +5 -0
  74. data/ext/cocor/mingwbuild.bat +2 -0
  75. data/ext/cocor/mkmf.log +57 -0
  76. data/ext/cocor/zipsources.bat +1 -0
  77. data/lib/cocor.rb +14 -0
  78. data/lib/ruco/version.rb +3 -0
  79. data/lib/ruco.rb +728 -0
  80. metadata +195 -0
@@ -0,0 +1,166 @@
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 <stdlib.h>
32
+ #include <wchar.h>
33
+ #include "CharSet.h"
34
+ #include "Scanner.h"
35
+
36
+ namespace Coco {
37
+
38
+ bool CharSet::Get(int i) const {
39
+ for (CharSet::Range *p = head; p != NULL; p = p->next)
40
+ if (i < p->from) return false;
41
+ else if (i <= p->to) return true; // p.from <= i <= p.to
42
+ return false;
43
+ }
44
+
45
+ void CharSet::Set(int i) {
46
+ Range *cur = head, *prev = NULL;
47
+ while (cur != NULL && i >= cur->from-1) {
48
+ if (i <= cur->to + 1) { // (cur.from-1) <= i <= (cur.to+1)
49
+ if (i == cur->from - 1) cur->from--;
50
+ else if (i == cur->to + 1) {
51
+ cur->to++;
52
+ Range *next = cur->next;
53
+ if (next != NULL && cur->to == next->from - 1) {
54
+ cur->to = next->to;
55
+ cur->next = next->next;
56
+ delete next;
57
+ };
58
+ }
59
+ return;
60
+ }
61
+ prev = cur; cur = cur->next;
62
+ }
63
+ Range *n = new Range(i, i);
64
+ n->next = cur;
65
+ if (prev == NULL) head = n; else prev->next = n;
66
+ }
67
+
68
+ CharSet* CharSet::Clone() const {
69
+ CharSet *s = new CharSet();
70
+ Range *prev = NULL;
71
+ for (Range *cur = head; cur != NULL; cur = cur->next) {
72
+ Range *r = new Range(cur->from, cur->to);
73
+ if (prev == NULL) s->head = r; else prev->next = r;
74
+ prev = r;
75
+ }
76
+ return s;
77
+ }
78
+
79
+ bool CharSet::Equals(CharSet *s) const {
80
+ Range *p = head, *q = s->head;
81
+ while (p != NULL && q != NULL) {
82
+ if (p->from != q->from || p->to != q->to) return false;
83
+ p = p->next; q = q->next;
84
+ }
85
+ return p == q;
86
+ }
87
+
88
+ int CharSet::Elements() const {
89
+ int n = 0;
90
+ for (Range *p = head; p != NULL; p = p->next) n += p->to - p->from + 1;
91
+ return n;
92
+ }
93
+
94
+ int CharSet::First() const {
95
+ if (head != NULL) return head->from;
96
+ return -1;
97
+ }
98
+
99
+ void CharSet::Or(CharSet *s) {
100
+ for (Range *p = s->head; p != NULL; p = p->next)
101
+ for (int i = p->from; i <= p->to; i++) Set(i);
102
+ }
103
+
104
+ void CharSet::And(CharSet *s) {
105
+ CharSet *x = new CharSet();
106
+ Range *p = head;
107
+ while (p != NULL) {
108
+ for (int i = p->from; i <= p->to; i++)
109
+ if (s->Get(i)) x->Set(i);
110
+ Range *del = p;
111
+ p = p->next;
112
+ delete del;
113
+ }
114
+ head = x->head;
115
+ x->head = NULL;
116
+ delete x;
117
+ }
118
+
119
+ void CharSet::Subtract(CharSet *s) {
120
+ CharSet *x = new CharSet();
121
+ Range *p = head;
122
+ while (p != NULL) {
123
+ for (int i = p->from; i <= p->to; i++)
124
+ if (!s->Get(i)) x->Set(i);
125
+ Range *del = p;
126
+ p = p->next;
127
+ delete del;
128
+ }
129
+ head = x->head;
130
+ x->head = NULL;
131
+ delete x;
132
+ }
133
+
134
+ bool CharSet::Includes(CharSet *s) const {
135
+ for (Range *p = s->head; p != NULL; p = p->next)
136
+ for (int i = p->from; i <= p->to; i++)
137
+ if (!Get(i)) return false;
138
+ return true;
139
+ }
140
+
141
+ bool CharSet::Intersects(CharSet *s) const {
142
+ for (Range *p = s->head; p != NULL; p = p->next)
143
+ for (int i = p->from; i <= p->to; i++)
144
+ if (Get(i)) return true;
145
+ return false;
146
+ }
147
+
148
+ void CharSet::Clear() {
149
+ while (head != NULL) {
150
+ Range *del = head;
151
+ head = head->next;
152
+ delete del;
153
+ }
154
+ }
155
+
156
+ void CharSet::Fill() {
157
+ Clear();
158
+ head = new Range(0, COCO_WCHAR_MAX);
159
+ }
160
+
161
+ CharSet::~CharSet() {
162
+ Clear();
163
+ }
164
+
165
+
166
+ }
@@ -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_CHARSET_H__)
30
+ #define COCO_CHARSET_H__
31
+
32
+ #include <stdio.h>
33
+
34
+ namespace Coco {
35
+
36
+ class CharSet {
37
+ public:
38
+ class Range {
39
+ public:
40
+ int from;
41
+ int to;
42
+ Range *next;
43
+ Range(int from, int to) { this->from = from; this->to = to; next = NULL; };
44
+ };
45
+
46
+ Range *head;
47
+
48
+ CharSet() { head = NULL; };
49
+ virtual ~CharSet();
50
+
51
+ bool Get(int i) const;
52
+ void Set(int i);
53
+ CharSet* Clone() const;
54
+ bool Equals(CharSet *s) const;
55
+ int Elements() const;
56
+ int First() const;
57
+ void Or(CharSet *s);
58
+ void And(CharSet *s);
59
+ void Subtract(CharSet *s);
60
+ bool Includes(CharSet *s) const;
61
+ bool Intersects(CharSet *s) const;
62
+ void Clear();
63
+ void Fill();
64
+ };
65
+
66
+ } // namespace
67
+
68
+ #endif // !defined(COCO_CHARSET_H__)