Basic Work
My calculator does all things that are described in Language note. Also, it follows the calculator grammar. I have a test file and its output
In this homework, I have three files in total 1)scan.rb scan input file and transfer it to Tokens 2)clac.rb get the tokens and do the calculation 3)hw8.txt this is a test file which contains the input that user gives and output the calculator returns
eg: input: 1+1 output: 2
Extra work
- Print meaningful message after assignment and clear statements.
- Extend the language by allowing empty lines (statements) in the input, allowing multiple statements on an input line separated by semicolons, or allowing unary minus operators
- I added a function called log to give the log of the expressions by using the Ruby math library.
- When it reads an invalid token like # or ' ', it will skip this unvalid line, print the meaningful message and continue to read next line.