void GreaterLess(EVAL *Part1) { EVAL Part2; shifts(Part1); GetOper(); if (IsOper(">")) { SkipOper(); GreaterLess(&Part2); Part1->Value = (Part1->Value > Part2.Value); return; } if (IsOper("<")) { SkipOper(); GreaterLess(&Part2); Part1->Value = (Part1->Value < Part2.Value); return; } if (IsOper(">=")) { SkipOper(); GreaterLess(&Part2); Part1->Value = (Part1->Value >= Part2.Value); return; } if (IsOper("<=")) { SkipOper(); GreaterLess(&Part2); Part1->Value = (Part1->Value <= Part2.Value); return; } }
void assign(EVAL *Part1) /* MAHandle assignments (=) */ { // EVAL Part2; logor(Part1); GetOper(); if (IsOper("=")) { SkipOper(); Error(Error_Skip, "'=' is not implemented yet"); ExitApp(1); } }
void Lexer(char* CharSource, Token* TokSource) { char* CurChar = CharSource; Token* CurToken = TokSource; while (*CurChar != '\0') { GetNum(&CurChar, &CurToken); GetOper(&CurChar, &CurToken); GetPar(&CurChar, &CurToken); SkipChar(&CurChar); } CurToken->type = END; size_t i = 0; while ( TokSource[i].type != END ) { switch (TokSource[i].type) { /* case OPER */ case ADDITIVE_OPER: ; case MULTIPLICATIVE_OPER: ; case POWER_OPER: printf("%c", TokSource[i].value.oper); break; /* case PAR */ case LPAR: case RPAR: printf("%c", TokSource[i].value.par); break; /* case NUM */ case NUM: printf("[%f]", TokSource[i].value.number); break; case END: break; default: fprintf(stderr, "unexpected token %d\n", TokSource[i].type); } i++; } printf("\n"); }
void shifts(EVAL *Part1) { EVAL Part2; plus(Part1); GetOper(); if (IsOper(">>")) { SkipOper(); shifts(&Part2); Part1->Value >>= Part2.Value; return; }
void or_ev(EVAL *Part1) /* MAHandle addition and substraction */ { EVAL Part2; and_ev(Part1); GetOper(); if (IsOper("|")) { SkipOper(); or_ev(&Part2); Part1->Value |= Part2.Value; return; } }
void logand(EVAL *Part1) /* MAHandle addition and substraction */ { EVAL Part2; xor_ev(Part1); GetOper(); if (IsOper("&&")) { SkipOper(); logand(&Part2); Part1->Value = (Part1->Value && Part2.Value); return; } }
void logor(EVAL *Part1) { EVAL Part2; logand(Part1); GetOper(); if (IsOper("||")) { SkipOper(); logor(&Part2); Part1->Value = (Part1->Value || Part2.Value); return; return; } }
void and_ev(EVAL *Part1) /* MAHandle addition and substraction */ { EVAL Part2; GreaterLess(Part1); GetOper(); if (IsOper("&")) { SkipOper(); and_ev(&Part2); Part1->Value &= Part2.Value; return; } if (IsOper("!=")) { SkipOper(); and_ev(&Part2); Part1->Value = ( Part1->Value != Part2.Value); return; } if (IsOper("==")) { SkipOper(); and_ev(&Part2); Part1->Value = (Part1->Value == Part2.Value); return; } }