-
Notifications
You must be signed in to change notification settings - Fork 0
/
mknodedecls.pl
executable file
·143 lines (118 loc) · 4.58 KB
/
mknodedecls.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/usr/bin/perl
#
$decls = $incls = '';
open NODES, "find nodes -name \\*.h -print |"
or die "Could not list node headers";
while (<NODES>) {
if (m/\ball\.h\b/) { next; }
chomp;
$decl = $incl = $_;
#
# Handle declaration
#
$i = $decl =~ s-(([[:alnum:]]|_)+)/-namespace $1 { -g;
$decl =~ s-(([[:alnum:]]|_)+?)\.h-class $1; -;
$decls .= $decl;
for ($j = 0; $j < $i; $j++) {
$decls .= "} ";
}
$decls .= "\n";
#
# Handle include
#
$incl =~ s/^/#include "/;
$incl =~ s/$/"/;
$incls .= "$incl\n";
}
close NODES;
# "nodes" (dir) in $decls should be "node" (namespace)
$decls =~ s/\bnodes\b/node/g;
chomp $decls;
###########################################################################
###########################################################################
###########################################################################
#
# File "nodes/all.h" will now be produced.
#
print<<__EOF__;
//
// **** AUTOMATICALLY GENERATED BY mknodedecls.pl -- DO NOT EDIT ****
//
#ifdef __NODE_DECLARATIONS_ONLY__
//---------------------------------------------------------------------------
// THESE ARE PREDEFINED NODES, AVAILABLE FROM THE CDK
//---------------------------------------------------------------------------
namespace cdk {
namespace node {
class Node; class Nil; class Data; class Composite; class Sequence;
namespace expression {
template <class T> class Simple;
class Double; class Integer; class String; class Identifier;
class UnaryExpression;
class NEG;
class BinaryExpression;
class ADD; class SUB; class MUL; class DIV; class MOD;
class LT; class LE; class GE; class GT; class EQ; class NE;
}
} // namespace node
} // namespace cdk
//---------------------------------------------------------------------------
// THESE ARE THE NODES DEFINED SPECIFICALLY FOR THIS APPLICATION
//---------------------------------------------------------------------------
namespace at {
$decls
} // namespace at
//---------------------------------------------------------------------------
// A L I A S E S
//---------------------------------------------------------------------------
// make sure the "semantics" namespace is known
namespace at { namespace semantics {} }
#else /* !defined(__NODE_DECLARATIONS_ONLY__) */
#ifndef __AUTOMATIC_NODE_ALLNODES_H__
#define __AUTOMATIC_NODE_ALLNODES_H__
//---------------------------------------------------------------------------
// THESE ARE PREDEFINED NODES, AVAILABLE FROM THE CDK
//---------------------------------------------------------------------------
#include <cdk/nodes/Node.h>
#include <cdk/nodes/Data.h>
#include <cdk/nodes/Nil.h>
#include <cdk/nodes/Composite.h>
#include <cdk/nodes/Sequence.h>
#include <cdk/nodes/expressions/Integer.h>
#include <cdk/nodes/expressions/Double.h>
#include <cdk/nodes/expressions/String.h>
#include <cdk/nodes/expressions/Identifier.h>
#include <cdk/nodes/expressions/NEG.h>
#include <cdk/nodes/expressions/ADD.h>
#include <cdk/nodes/expressions/SUB.h>
#include <cdk/nodes/expressions/MUL.h>
#include <cdk/nodes/expressions/DIV.h>
#include <cdk/nodes/expressions/MOD.h>
#include <cdk/nodes/expressions/LT.h>
#include <cdk/nodes/expressions/GT.h>
#include <cdk/nodes/expressions/GE.h>
#include <cdk/nodes/expressions/LE.h>
#include <cdk/nodes/expressions/NE.h>
#include <cdk/nodes/expressions/EQ.h>
//---------------------------------------------------------------------------
// THESE ARE THE NODES DEFINED SPECIFICALLY FOR THIS APPLICATION
//---------------------------------------------------------------------------
$incls
//---------------------------------------------------------------------------
// A L I A S E S
//---------------------------------------------------------------------------
// make sure the "semantics" namespace is known
namespace at { namespace semantics {} }
//---------------------------------------------------------------------------
// T H E E N D
//---------------------------------------------------------------------------
#endif /* !defined(__AUTOMATIC_NODE_ALLNODES_H__) */
#endif /* !defined(__NODE_DECLARATIONS_ONLY__) */
__EOF__
###########################################################################
###########################################################################
###########################################################################
0;
###########################################################################
###########################################################################
###########################################################################