YACC and LEX question

YACC and LEX question

Post by Gary Barwi » Sun, 10 Sep 1995 04:00:00

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


The Problem

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:

(i)     12345
(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.


1. Simple lex v. yacc question

I have never used either lex or yacc, but I read the documentation
for both. I have no idea which is better suited for my task though.
Basically, I have a simple file format in which I have multiple items,
each with different attributes. Each item is bounded by { }, and the
attributes are not all necessarily present. They are case-insensitive
and predefined. Comments are permitted. For example:

% foo
{ NAME = foo; COLOR=bar; QUANTITY=3} {name=fubar} {name =barfoo;;; COLOR=blue}

Should I use lex and or yacc?
Thank you very much


                                                joseph p turian

"I must Create a System or be enslav'd by another Man's.
I will not Reason & Compare: my business is to Create."
---William Blake

2. Help with Samba , please !

3. Lex (Flex) and Yacc (or Bison) questions.

4. /dev/lp0 : no such device on my new P90-PCI

5. LEX / YACC yywrap() question

6. malloc'd memory after a process is killed

7. Followup YACC & LEX Question

8. Microsoft to code on GNOME...

9. YACC and LEX question

10. lex/yacc question

11. lex, yacc question

12. Yacc & Lex Question

13. lex/yacc/cc/unix question