Consider expressions built up from natural numbers using a subtraction operator that is assumed to associate to
Fantastic news! We've Found the answer you've been seeking!
Question:
Consider expressions built up from natural numbers using a subtraction operator that is assumed to associate to the left.
(a) Define a natural grammar for such expressions.
(b) Translate this grammar into a parser expr: Parser Int.
(c) What is the problem with this parser?
(d) Show how it can be fixed. Hint: rewrite the parser using the repetition primitive many and the library function foldl.
Related Book For
Introduction To Probability And Statistics
ISBN: 9781133103752
14th Edition
Authors: William Mendenhall, Robert Beaver, Barbara Beaver
Posted Date: