Files
hlang/parser3.c

42 lines
745 B
C
Raw Normal View History

2025-11-05 14:28:45 +03:00
#include "./lexer.h"
2025-11-05 16:03:14 +03:00
int get_prec(symbols op){
switch (op) {
case TOKEN_MUL:
case TOKEN_DIV:
return 2; break;
case TOKEN_PLUS:
case TOKEN_MINUS:
return 1; break;
default: return 0;
}
}
// parse
bool is_left_asc(symbols op){
switch (op) {
case TOKEN_MUL:
case TOKEN_DIV:
case TOKEN_PLUS:
case TOKEN_MINUS:
return true; break;
default: return false;
}
}
void build_rpn();
2025-11-05 14:28:45 +03:00
int main(void){
2025-11-05 15:27:57 +03:00
const char ts[] = "\"hello\" hi + 2";
const char math[] = "((1+2)*6)/18"; // = 1
Token tk = tokenize_all(math);
2025-11-05 14:28:45 +03:00
for (size_t i=0; i<tk.size; ++i){
2025-11-05 15:27:57 +03:00
printf("TokenNum: %zu Type: %s Value: %s\n", i, tk.tktype[i], tk.text[i]);
2025-11-05 14:28:45 +03:00
}
// printf("token count: %zu\n", tk.size);
}