Here Is A Link To A Simple Calculator In Lex And Yacc Implementing Something Lik

here is a link to a simple calculator in lex and yacc, implementing something like our example expression grammar calculator

This is calc.lex and calc.yacc from Andrew Brinker – you may use these as youy starting point instead of the first link

1. Implement it

> 2. Add and exit/quit feature, so that you can enter one expression and then use the result as the start of another expression – for example:

2+5 => 7

/2 => 3.5

3. Add variables to the grammar – this requires modifying the grammar with an assign statement so you can set the values of a variable, and a print ot display statement so you can view the contents of the variable. You may implement it as an interpreter or a compiler

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *