out.s now out.mys and debug added
This commit is contained in:
parent
36270c87a4
commit
14a762bfe6
@ -13,7 +13,6 @@
|
|||||||
F661C333214590930021FCCE /* parser.c in Sources */ = {isa = PBXBuildFile; fileRef = F661C332214590930021FCCE /* parser.c */; };
|
F661C333214590930021FCCE /* parser.c in Sources */ = {isa = PBXBuildFile; fileRef = F661C332214590930021FCCE /* parser.c */; };
|
||||||
F661C3362145CE760021FCCE /* ast.c in Sources */ = {isa = PBXBuildFile; fileRef = F661C3352145CE760021FCCE /* ast.c */; };
|
F661C3362145CE760021FCCE /* ast.c in Sources */ = {isa = PBXBuildFile; fileRef = F661C3352145CE760021FCCE /* ast.c */; };
|
||||||
F661C3392145D9C40021FCCE /* generate.c in Sources */ = {isa = PBXBuildFile; fileRef = F661C3382145D9C40021FCCE /* generate.c */; };
|
F661C3392145D9C40021FCCE /* generate.c in Sources */ = {isa = PBXBuildFile; fileRef = F661C3382145D9C40021FCCE /* generate.c */; };
|
||||||
F661C33C2145DF370021FCCE /* out.s in Sources */ = {isa = PBXBuildFile; fileRef = F661C33B2145DF370021FCCE /* out.s */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
@ -29,6 +28,7 @@
|
|||||||
/* End PBXCopyFilesBuildPhase section */
|
/* End PBXCopyFilesBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
F606D3182145FAB300E817B6 /* out.mys */ = {isa = PBXFileReference; lastKnownFileType = text; path = out.mys; sourceTree = "<group>"; };
|
||||||
F619105D2142A876003B8798 /* cinc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cinc; sourceTree = BUILT_PRODUCTS_DIR; };
|
F619105D2142A876003B8798 /* cinc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = cinc; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
F61910602142A876003B8798 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
F61910602142A876003B8798 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
||||||
F61910672142A8C5003B8798 /* tokenize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tokenize.h; sourceTree = "<group>"; };
|
F61910672142A8C5003B8798 /* tokenize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = tokenize.h; sourceTree = "<group>"; };
|
||||||
@ -41,7 +41,6 @@
|
|||||||
F661C3372145D9C40021FCCE /* generate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = generate.h; sourceTree = "<group>"; };
|
F661C3372145D9C40021FCCE /* generate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = generate.h; sourceTree = "<group>"; };
|
||||||
F661C3382145D9C40021FCCE /* generate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = generate.c; sourceTree = "<group>"; };
|
F661C3382145D9C40021FCCE /* generate.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = generate.c; sourceTree = "<group>"; };
|
||||||
F661C33A2145DE300021FCCE /* token.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = token.h; sourceTree = "<group>"; };
|
F661C33A2145DE300021FCCE /* token.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = token.h; sourceTree = "<group>"; };
|
||||||
F661C33B2145DF370021FCCE /* out.s */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.asm; path = out.s; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -85,7 +84,7 @@
|
|||||||
F661C3352145CE760021FCCE /* ast.c */,
|
F661C3352145CE760021FCCE /* ast.c */,
|
||||||
F661C3372145D9C40021FCCE /* generate.h */,
|
F661C3372145D9C40021FCCE /* generate.h */,
|
||||||
F661C3382145D9C40021FCCE /* generate.c */,
|
F661C3382145D9C40021FCCE /* generate.c */,
|
||||||
F661C33B2145DF370021FCCE /* out.s */,
|
F606D3182145FAB300E817B6 /* out.mys */,
|
||||||
);
|
);
|
||||||
path = cinc;
|
path = cinc;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -147,7 +146,6 @@
|
|||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
F65A954E21454B31005FCAF5 /* token.c in Sources */,
|
F65A954E21454B31005FCAF5 /* token.c in Sources */,
|
||||||
F661C33C2145DF370021FCCE /* out.s in Sources */,
|
|
||||||
F661C3362145CE760021FCCE /* ast.c in Sources */,
|
F661C3362145CE760021FCCE /* ast.c in Sources */,
|
||||||
F61910692142A8C5003B8798 /* tokenize.c in Sources */,
|
F61910692142A8C5003B8798 /* tokenize.c in Sources */,
|
||||||
F661C333214590930021FCCE /* parser.c in Sources */,
|
F661C333214590930021FCCE /* parser.c in Sources */,
|
||||||
|
26
cinc/main.c
26
cinc/main.c
@ -14,14 +14,36 @@
|
|||||||
#include "parser.h"
|
#include "parser.h"
|
||||||
#include "generate.h"
|
#include "generate.h"
|
||||||
|
|
||||||
|
#define PARSER_DEBUG 0
|
||||||
|
|
||||||
int main(int argc, const char * argv[]) {
|
int main(int argc, const char * argv[]) {
|
||||||
char* prgstr="int main() {\nreturn 0;\n}";
|
char* prgstr="int main() {\n return 173;\n}\n";
|
||||||
|
if (PARSER_DEBUG) {
|
||||||
|
printf("Program:\n");
|
||||||
|
printf("%s",prgstr);
|
||||||
|
}
|
||||||
Token* tokens=tokenize(prgstr);
|
Token* tokens=tokenize(prgstr);
|
||||||
|
if (PARSER_DEBUG) {
|
||||||
|
printf("Tokens:\n");
|
||||||
|
Token* tok=tokens;
|
||||||
|
while (tok) {
|
||||||
|
print_tok(tok);
|
||||||
|
tok=tok->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
AstNode* ast=parse(tokens);
|
AstNode* ast=parse(tokens);
|
||||||
free_toklist(tokens);
|
free_toklist(tokens);
|
||||||
|
if (PARSER_DEBUG) {
|
||||||
|
printf("AST:\n");
|
||||||
|
print_tree(ast, 0);
|
||||||
|
}
|
||||||
char* prg=generate_prg(ast);
|
char* prg=generate_prg(ast);
|
||||||
free_tree(ast);
|
free_tree(ast);
|
||||||
FILE* outfile=fopen("/Users/peterterpstra/Desktop/projects/xcode/cinc/cinc/out.s","w");
|
if (PARSER_DEBUG) {
|
||||||
|
printf("Output assembly:\n");
|
||||||
|
printf("%s",prg);
|
||||||
|
}
|
||||||
|
FILE* outfile=fopen("/Users/peterterpstra/Desktop/projects/xcode/cinc/cinc/out.mys","w");
|
||||||
fputs(prg, outfile);
|
fputs(prg, outfile);
|
||||||
fclose(outfile);
|
fclose(outfile);
|
||||||
free(prg);
|
free(prg);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.globl _main
|
.globl _main
|
||||||
_main:
|
_main:
|
||||||
mov rax,0
|
mov rax,173
|
||||||
ret
|
ret
|
Loading…
Reference in New Issue
Block a user