-
Notifications
You must be signed in to change notification settings - Fork 0
/
mknodedecls.pl
executable file
·122 lines (102 loc) · 3.72 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
#!/usr/bin/perl
# $Id: mknodedecls.pl,v 1.1 2016/02/19 19:29:48 david Exp $
#
$decls = $incls = '';
open NODES, "find ast -name \\*.h -print | sed -e 's=ast/==g' | "
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 "ast/=;
$incl =~ s/$/"/;
$incls .= "$incl\n";
}
close NODES;
###########################################################################
#
# 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 {
class basic_node; class nil_node; class data_node;
class composite_node; class sequence_node; class expression_node;
template <typename StoredType> class simple_value_node;
class double_node; class integer_node; class string_node;
class identifier_node;
class unary_expression_node;
class neg_node;
class binary_expression_node;
class add_node; class sub_node; class mul_node; class div_node;
class mod_node; class lt_node; class le_node; class ge_node;
class gt_node; class eq_node; class ne_node;
} // namespace cdk
//---------------------------------------------------------------------------
// THESE ARE THE NODES DEFINED SPECIFICALLY FOR THIS APPLICATION
//---------------------------------------------------------------------------
namespace zu {
$decls
} // namespace zu
//---------------------------------------------------------------------------
// A L I A S E S
//---------------------------------------------------------------------------
#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/ast/basic_node.h>
#include <cdk/ast/data_node.h>
#include <cdk/ast/nil_node.h>
#include <cdk/ast/composite_node.h>
#include <cdk/ast/sequence_node.h>
#include <cdk/ast/integer_node.h>
#include <cdk/ast/double_node.h>
#include <cdk/ast/string_node.h>
#include <cdk/ast/identifier_node.h>
#include <cdk/ast/neg_node.h>
#include <cdk/ast/add_node.h>
#include <cdk/ast/sub_node.h>
#include <cdk/ast/mul_node.h>
#include <cdk/ast/div_node.h>
#include <cdk/ast/mod_node.h>
#include <cdk/ast/lt_node.h>
#include <cdk/ast/gt_node.h>
#include <cdk/ast/ge_node.h>
#include <cdk/ast/le_node.h>
#include <cdk/ast/ne_node.h>
#include <cdk/ast/eq_node.h>
//---------------------------------------------------------------------------
// THESE ARE THE NODES DEFINED SPECIFICALLY FOR THIS APPLICATION
//---------------------------------------------------------------------------
$incls
//---------------------------------------------------------------------------
// T H E E N D
//---------------------------------------------------------------------------
#endif /* !defined(__AUTOMATIC_NODE_ALLNODES_H__) */
#endif /* !defined(__NODE_DECLARATIONS_ONLY__) */
__EOF__
###########################################################################
0;
###########################################################################