Hello all unix programmers,
Can you please help me? I have an assignment to do for university
and haven't a clue how to do it. The Lecturer has not been very
helpful and time is running out. If anyone out there can help I
would be very happy if you could post me a solution or at least
how to do it. It is a minor, my main purpose is to learn how to use
YACC and LEX!
Demonstrate your understanding to LEX and YACC specifications by designing,
implementing and testing a LEX/YACC specification for a recogniser for uni-variate
polynomials with real co-efficients and non-negative exponents. You may assume
the "variable" is only "x". The acceptable format of such polynomials should
be flexible as is sensible. Illegal polynomials MUST be reported and rejected.
In a single run of the recogniser a sequence of polynomials (NOT just one) should
be recognised (simpler error recover should be designed-in).
By the way of acceptable sample polynomials, I consider the following as minimal:
(ii) 123.456x + 75x - x^3 + x^9
(iii) +3x^5 + x^0 - 65.4 -7x^12
1. the "order" of the powers of x should be irrelevant
2. it should be possible to have the same power appearing more than once.
3. while the examples above did not have any co-efficients with exponents, this
would be useful.
4. develop your design - start out simple (e.g. integer coefficients and other
simplifying assumptions) and then relax the restrictions one at a time.
5. your design description should be for the complete "polynomial" even though
your implementation may not be as complete.
6. use railroad diagrams as well as YACC notation to describe your mini-lannguage.