Question: Given the simple calculator (Syntax: slide 16; textbook: p.54), give an example of input code that produces exactly three errors from the scanner. The scanner
Given the simple calculator (Syntax: slide 16; textbook: p.54), give an example of input code that produces exactly three errors from the scanner. The scanner encounters an error when reading an invalid token. When that happens, assume that the scanner skips everything until the next white space (\ ,\t, ). Your three invalid tokens should start with three different characters. Your input code will be a string over the alphabet {a,b,...,z,0,1,...,9,:,=,+,-,*,/,(,),\ ,\t, }. Explain in detail how the three errors are produced from the scanner.
. Example: simple calculator language ++ assign (Algol style; C has =') plus minus + - times * div Iparen ( rparen ) id - letter (letter | digit )* (except for read and write) number digit digit* | digit* ( . digit | digit . ) digit* comment /* ( non-* | * non-/ )* *+/ 177 (non-newline)* newline 16 . Example: simple calculator language ++ assign (Algol style; C has =') plus minus + - times * div Iparen ( rparen ) id - letter (letter | digit )* (except for read and write) number digit digit* | digit* ( . digit | digit . ) digit* comment /* ( non-* | * non-/ )* *+/ 177 (non-newline)* newline 16
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
