rename compiler to codegen + handle file not found
parent
49183bf1d3
commit
9a97b73c7c
|
@ -40,11 +40,11 @@ add_executable(
|
|||
lib/dropt/dropt_handlers.c
|
||||
# Source
|
||||
src/ast.h
|
||||
src/compiler.h
|
||||
src/codegen.h
|
||||
src/parser.h
|
||||
src/stack.h
|
||||
src/ast.c
|
||||
src/compiler.c
|
||||
src/codegen.c
|
||||
src/parser.c
|
||||
src/stack.c
|
||||
src/main.c
|
||||
|
|
|
@ -813,7 +813,7 @@ static void Compile(LLVMModuleRef module, LLVMContextRef context, Node *node)
|
|||
}
|
||||
}
|
||||
|
||||
int Build(Node *node, uint32_t optimizationLevel)
|
||||
int Codegen(Node *node, uint32_t optimizationLevel)
|
||||
{
|
||||
scope = CreateScope();
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef WRAITH_CODEGEN_H
|
||||
#define WRAITH_CODEGEN_H
|
||||
|
||||
#include "ast.h"
|
||||
|
||||
int Codegen(Node *node, uint32_t optimizationLevel);
|
||||
|
||||
#endif /* WRAITH_CODEGEN_H */
|
|
@ -1,8 +0,0 @@
|
|||
#ifndef WRAITH_COMPILER_H
|
||||
#define WRAITH_COMPILER_H
|
||||
|
||||
#include "ast.h"
|
||||
|
||||
int Build(Node *node, uint32_t optimizationLevel);
|
||||
|
||||
#endif /* WRAITH_COMPILER_H */
|
|
@ -2,7 +2,7 @@
|
|||
#include "../lib/dropt/dropt.h"
|
||||
|
||||
#include "parser.h"
|
||||
#include "compiler.h"
|
||||
#include "codegen.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
exitCode = Build(rootNode, optimizationLevel);
|
||||
exitCode = Codegen(rootNode, optimizationLevel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
src/parser.c
14
src/parser.c
|
@ -14,9 +14,17 @@ int Parse(char *inputFilename, Node **pRootNode, uint8_t parseVerbose)
|
|||
yydebug = parseVerbose;
|
||||
|
||||
FILE *fp = fopen(inputFilename, "r");
|
||||
yyin = fp;
|
||||
result = yyparse(fp, stack, pRootNode);
|
||||
fclose(fp);
|
||||
if (fp != NULL)
|
||||
{
|
||||
yyin = fp;
|
||||
result = yyparse(fp, stack, pRootNode);
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "File not found.\n");
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* TODO: free stack */
|
||||
/* TODO: free AST on error */
|
||||
|
|
Loading…
Reference in New Issue