/
ast_main.c
105 lines (74 loc) · 1.64 KB
/
ast_main.c
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
/*
Copyright: 2001-2004 The Perl Foundation. All Rights Reserved.
$Id$
=head1 NAME
ast/ast_main.c - AST compiler
=head1 DESCRIPTION
The AST (Abstract Syntax Tree) represents the code of a HLL source module.
=head2 Functions
=over 4
=cut
*/
#include "../imcc/imc.h"
#include "parrot/method_util.h"
#include "ast.h"
extern FILE* ASTin;
extern void ASTparse(Interp *);
PMC * ast_compile_past(Interp *interpreter, const char *src_string);
PMC *
ast_compile_past(Interp *interpreter, const char *src_string)
{
IMCC_fatal(interpreter, 1, "ast_compile_past: unimplemented");
return NULL;
}
/*
=item C<IMCC_ast_compile(Interp *, FILE *fp)>
Compile AST source file to bytecode
=cut
*/
void
IMCC_ast_compile(Interp *interpreter, FILE *fp)
{
nodeType *top_node;
SymReg *sym;
ASTin = fp;
ASTparse(interpreter);
top_node = interpreter->imc_info->top_node;
if (top_node) {
sym = IMCC_expand_nodes(interpreter, top_node);
if (interpreter->imc_info->debug & DEBUG_AST) {
IMCC_dump_nodes(interpreter, top_node);
}
IMCC_free_nodes(interpreter, top_node);
}
interpreter->imc_info->top_node = NULL;
}
static void
register_ast_compiler(Interp* interpreter)
{
STRING *past = const_string(interpreter, "PAST");
Parrot_compreg(interpreter, past, ast_compile_past);
}
/*
=item C<IMCC_ast_init(Interp*)>
Initialize the AST compiler
=cut
*/
void
IMCC_ast_init(Interp* interpreter)
{
register_ast_compiler(interpreter);
}
/*
=back
=cut
*/
/*
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
* indent-tabs-mode: nil
* End:
*
* vim: expandtab shiftwidth=4:
*/