Construct Context-free Grammar for unsigned real numbers with coma. Each number has the same number of digits before the decimal and after decimal. Example: 0,0; 0090,1117; 1,9; are correct, but 0,00; 90,1117; 1,90; , are incorrect. I have something like this:
(real) ::= (digit) (digit) (decimal part)
(digit*) ::= (digit) (digit*) | epsilon
(decimal part) ::= ',' (digit) (digit*) | epsilon
(digit) ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
I know it's incorrect, because my syntax allows 1,90, but I have no idea how to fix this. Please, help me :)
You need to generate the integer and decimal parts simultaneously:
$$\text{(real)}::=\text{(digit)},\text{(digit)}\mid\text{(digit)}\text{(real)}\text{(digit)}$$