I'm trying to make sure if i did a) correct. I believe it makes sense, just trying to see if anyone has any suggestions.
The grammar
G=<V,T,P,calculation>
for the calculator language is defined by:
V={calculation, expression, value, number, unsigned, digit, sign, operator} T={0,1,2,3,4,5,6,7,8,9,+,-,*,/,=,.}
P consists of the following productions (rules):
- calculation -> expression =
- expression -> value | value operator expression
- value -> number | sign number
- number -> unsigned | unsigned . unsigned
- unsigned -> digit | digit unsigned
- digit -> 0| 1| 2| 3| 4| 5| 6| 7| 8| 9
- sign -> + | -
- operator -> +| -| *| /
Show:
(a) 100/2.5= is in the calculator language;
My answer:
a.
<calculation>
=> <expression> =
=> <value> <operator> <expression>
=> <value> / <expression>
=> <number> / <expression>
=> <number> / <value>
=> <number> / <number>
=> <unsigned> / <unsigned . unsigned>
=> <digit><unsigned> / <digit . digit>
=> 1<digit><unsigned> / 2.5
=> 10<digit> / 2.5
=> 100 / 2.5
<unsigned> . <unsigned>rather than<unsigned . unsigned>. – dtldarek Feb 02 '15 at 09:13=>already. More importantly, if that detail is important for your TA, then I would change the group/course or even school if that's a prevalent attitude (although it may be justified if it is about readability in some concrete programming language, but it's not that case here). – dtldarek Feb 02 '15 at 09:27