pikapython/src/PikaParser.c

43 lines
1.0 KiB
C
Raw Normal View History

2021-10-13 18:05:54 +08:00
#include "PikaParser.h"
#include "PikaObj.h"
#include "dataQueueObj.h"
#include "dataStrs.h"
2021-10-13 19:41:04 +08:00
AST* AST_parseStmt(AST* ast, char* stmt) {
2021-10-13 18:05:54 +08:00
Args* buffs = New_strBuff();
2021-10-13 18:24:38 +08:00
char* assignment = strsGetFirstToken(buffs, stmt, '(');
2021-10-13 18:05:54 +08:00
char* direct = NULL;
2021-10-13 18:24:38 +08:00
char* method = NULL;
2021-10-13 18:05:54 +08:00
if (strIsContain(assignment, '=')) {
direct = strsGetFirstToken(buffs, assignment, '=');
2021-10-13 19:41:04 +08:00
obj_setStr(ast, "direct", direct);
2021-10-13 19:32:00 +08:00
method = strsGetLastToken(buffs, assignment, '=');
2021-10-13 18:05:54 +08:00
}
2021-10-13 18:24:38 +08:00
method = assignment;
2021-10-13 19:41:04 +08:00
obj_setStr(ast, "method", method);
2021-10-13 18:24:38 +08:00
char* subStmts = strsCut(buffs, stmt, '(', ')');
2021-10-13 18:05:54 +08:00
goto exit;
exit:
args_deinit(buffs);
return ast;
}
2021-10-13 19:41:04 +08:00
AST* pikaParse(char* line) {
AST* ast = New_queueObj();
Args* buffs = New_strBuff();
char* stmt = strsGetCleanCmd(buffs, stmt);
ast = AST_parseStmt(ast, stmt);
goto exit;
exit:
args_deinit(buffs);
return ast;
}
2021-10-13 18:05:54 +08:00
char* AST_toShell(AST* ast, Args* buffs) {
return NULL;
}
int32_t AST_deinit(AST* ast) {
return obj_deinit(ast);
}