You are browsing as a guest. Sign up (or log in) to start making projects!

1h 36m logged

Debugging Day

  1. fixed unary negative operation on a function like -sqrt in the tokenizer.

  2. added support for implicit multiplication in the tokenizer (right now only valid for alphabets after numbers like 3x, 25x, etc. and not for alphabet after alphabet like xsin(x), xlog(x), etc.)

  3. fixed the decimal point collection in the tokenizer due to the failed test case: -.5

  4. Added support for exponents by adding parse_pow().

  5. initially i had simply copied the structure of parse_add and parse_mul and ran the test case but i found out that the result was wrong. My current parsing algorithm has natural left associativity, which is required for other operators but, is wrong for power. Because, 2^3^2 should result in 2^(3^4) and not (2^3)^4, which means i needed right associativity.

  6. For getting right associativity, i had to make it such that the right term of the node was recursively calling parse_pow(), so that everything after it would get parsed first which would give us right associativity.

0
18

Comments 2

@Falling10fruit

Oh cool, so you’re using recursion or are you saving some tokens into stack/FIFO data structure?

@R10

i am using recursion. you can see my earlier devlogs for in depth updates on the tokenizer and parser because this is just something i put together quickly as the updates were pretty small. The final objective is to build a AST so i do not need to save the tokens into a different data structure as These nodes are what forms an AST which in itself is a data structure. It is pretty complex tbh (atleast for me) but surprisingly once i understood it, coding it was not a challenge.