2021-11-28 21:25:25 +08:00
|
|
|
#include <stdarg.h>
|
2021-11-28 20:32:09 +08:00
|
|
|
#include <stdio.h>
|
2021-11-28 21:25:25 +08:00
|
|
|
#include <stdlib.h>
|
2021-11-28 20:32:09 +08:00
|
|
|
#include "PikaObj.h"
|
2021-11-28 21:25:25 +08:00
|
|
|
#include "PikaParser.h"
|
|
|
|
#include "dataStrs.h"
|
|
|
|
|
2022-03-24 18:04:32 +08:00
|
|
|
PikaObj* __pikaMain;
|
|
|
|
|
2021-11-28 22:29:25 +08:00
|
|
|
void main() {
|
|
|
|
FILE* file_mian_py = fopen("main.py", "rb");
|
|
|
|
if (NULL == file_mian_py) {
|
|
|
|
printf("[error]: main.py no found. \r\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
fseek(file_mian_py, 0, SEEK_END);
|
|
|
|
long fsize = ftell(file_mian_py);
|
|
|
|
fseek(file_mian_py, 0, SEEK_SET); /* same as rewind(f); */
|
|
|
|
char* pyText = malloc(fsize + 1);
|
|
|
|
fread(pyText, 1, fsize, file_mian_py);
|
|
|
|
fclose(file_mian_py);
|
|
|
|
pyText[fsize] = 0;
|
|
|
|
|
|
|
|
Args* buffs = New_strBuff();
|
|
|
|
char* pika_byte_code = Parser_multiLineToAsm(buffs, pyText);
|
|
|
|
|
2022-03-24 18:12:18 +08:00
|
|
|
FILE* file_byte_code = fopen("pikaAsm.txt", "w");
|
2021-11-28 22:29:25 +08:00
|
|
|
fputs(pika_byte_code, file_byte_code);
|
|
|
|
args_deinit(buffs);
|
2022-03-24 18:12:18 +08:00
|
|
|
printf("[ OK ]: write file to 'pikaAsm.txt'. \r\n");
|
2021-11-28 22:29:25 +08:00
|
|
|
|
2022-03-24 18:19:07 +08:00
|
|
|
Parser_compilePyToBytecodeArray(pyText);
|
|
|
|
printf("\r\n\r\npress any key to exit...\r\n");
|
|
|
|
getchar();
|
|
|
|
|
2021-11-28 22:29:25 +08:00
|
|
|
return;
|
|
|
|
}
|