Create a simple EBNF that covers decimal numbers with punctuation including commas, decimal point, and sign (+/-).
Valid numbers:
digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
wholeNumber = digit {digit};
integer = ["+"|"-"] wholeNumber;
real = integer "." wholeNumber;
formatted = integer {"," wholeNumber} ["." wholeNumber];
-----------------------
Explaination :
digit ==>Numbers from 0 to 9
wholeNumber ==> whole number consist of atleast one digit followed by zero or more digits
integer ==> integers are just whole numbers with optional sign of + or - in front of them
real ==> are integers plus a decimal followed by whole numbers
formatted ==> It contains , as well it is integer followed by a sequence of zero or more combination of , and whole number and finally if decimal then followed by whole numbers which is optional
Get Answers For Free
Most questions answered within 1 hours.