[comp.lang.c] yacc

ins624y@monu4.cc.monash.edu.au (mr r. walker) (09/30/90)

Hi!
   At the moment I am attempting to write a parses for integer
infix maths formulas, using that dynamic duo Lex and Yacc.

I am not having much luck --- if anyone out there could email me
the yacc and/or lex code to do this I would be *VERY* grateful
(unfortunately, I do not have a pretty sister .... well, there
go all the females who were going to help me out ....)

I doesn't have to be a flash all-singing all-dancing parses ---
all I want it to do is calculate expressions like
1+2*3+(45+3)/4 --- no variables, only integer expressions
(ie. a/b only gives the integer part of the answer).



HHHeeelllpppp!!!!


Thanks, Rod.

smd@vab02.larc.nasa.gov (Steve M. Dahmen) (10/01/90)

In article <4746@monu1.cc.monash.oz> ins624y@monu4.cc.monash.edu.au (mr  r.   walker) writes:
>
>
>   At the moment I am attempting to write a parses for integer
>infix maths formulas, using that dynamic duo Lex and Yacc.
>
>I am not having much luck --- if anyone out there could email me
>the yacc and/or lex code to do this I would be *VERY* grateful

Amen!

Might there be one to work with floating point and strings as well
floating around anywhere?

Beginning YACCer,

Steve Dahmen

-- 
Steve Dahmen, Systems Analyst                         (804) 864-4519 (W)
Space Systems Division, Vehicle Analysis Branch
M/S 365, NASA Langley Research Center
Hampton, Virginia  23665                       smd@vab02.larc.nasa.gov

henry@zoo.toronto.edu (Henry Spencer) (10/02/90)

In article <4746@monu1.cc.monash.oz> ins624y@monu4.cc.monash.edu.au (mr  r.   walker) writes:
>   At the moment I am attempting to write a parses for integer
>infix maths formulas, using that dynamic duo Lex and Yacc.

Pardon the cynicism, but this wouldn't happen to be a homework assignment,
would it?

Recommended reading is "The UNIX Programming Environment", by Brian W.
Kernighan and Rob Pike, Prentice-Hall 1984.  Chapter 8 discusses doing
almost exactly what you're after.

Being cynical again, beware that your instructor has undoubtedly seen
K&P and will recognize a straight copy from it. :-)
-- 
Imagine life with OS/360 the standard  | Henry Spencer at U of Toronto Zoology
operating system.  Now think about X.  |  henry@zoo.toronto.edu   utzoo!henry

mhill@fiveliter.EBay.Sun.COM (Maurice Hill) (10/03/90)

henry@zoo.toronto.edu (Henry Spencer) writes:

>Being cynical again, beware that your instructor has undoubtedly seen
>K&P and will recognize a straight copy from it. :-)

and he/she may also read this group!!!

mef@romulus.rutgers.edu (Marc E. Fiuczynski) (04/05/91)

This is a desperate move.  I need a good example of a yacc grammar.
If you have that you would like to share with me please send it to 
me via e-mail.  I'm trying to use yacc learning/reading the sun manual
and I'm not getting anywhere.  Please, if you can send me a yacc grammar
that you wrote I would really appreciate it.  

The reason for this urgency is that I am working on an (independent)
project for school and I am getting stuck on using yacc.

Thanks in advance!
-Marc
-- 
______________________________________________________________________________
Marc E. Fiuczynski	\\  Home: (609) 683-4416	School: (908) 878-9388
mef@remus.rutgers.edu  	//  UUCP: {backbone}!rutgers!remus.rutgers.edu!mef

gwyn@smoke.brl.mil (Doug Gwyn) (04/06/91)

In article <Apr.5.00.38.07.1991.2057@romulus.rutgers.edu> mef@romulus.rutgers.edu (Marc E. Fiuczynski) writes:
>This is a desperate move.  I need a good example of a yacc grammar.

This wasn't really a C question, but since you bring it up,
I'd like to remark that the best tutorial on the use of yacc
that I know of is the development of the "hoc" utility in
Kernighan and Pike's "The UNIX Programming Environment",
available in better bookstores everywhere.

jseymour@medar.com (James Seymour) (04/06/91)

In article <Apr.5.00.38.07.1991.2057@romulus.rutgers.edu> mef@romulus.rutgers.edu (Marc E. Fiuczynski) writes:
>This is a desperate move.  I need a good example of a yacc grammar.

What you really need, IMHO, is a copy of "The UNIX Programming Environment"
by Kernighan and Pike.  There is a complete chapter on yacc (with lex also
covered briefly).  In that chapter is a complete example of a yacc program
that they call "hoc" (high order calculator).  In the example, hoc is
implemented in steps, starting with the simplest concepts and working up to
the more complex.  Each iteration of the program (there are, I think, five
or six) adds new concepts.  I recommend it highly.  Be warned, there are a
couple of design/coding snafus.  Boy, did I learn a lot about how that
program works from tracking those down :-).  On the other hand, these did
not bite me until I went on to "extending" the thing.

>Thanks in advance!
>-Marc
>-- 
>______________________________________________________________________________
>Marc E. Fiuczynski	\\  Home: (609) 683-4416	School: (908) 878-9388
>mef@remus.rutgers.edu  	//  UUCP: {backbone}!rutgers!remus.rutgers.edu!mef


-- 
Jim Seymour				| Medar, Inc.
...!uunet!medar!jseymour		| 38700 Grand River Ave.
jseymour@medar.com			| Farmington Hills, MI. 48331
CIS: 72730,1166  GEnie: jseymour	| FAX: (313)477-8897

gwyn@smoke.brl.mil (Doug Gwyn) (04/08/91)

In article <109@hdwr1.medar.com> jseymour@medar.com (James Seymour) writes:
>Be warned, there are a couple of design/coding snafus [in "hoc"].

I think our local version has most or perhaps all of these stamped out,
plus I typed up the manual for "hoc" (in -ms format).  If you're actually
using "hoc" and are concerned about porting it, feel free to contact me
for a copy of our "hoc" sources.

stanley@phoenix.com (John Stanley) (04/08/91)

mef@romulus.rutgers.edu (Marc E. Fiuczynski) writes:

> This is a desperate move.  I need a good example of a yacc grammar.
> If you have that you would like to share with me please send it to 
> me via e-mail.  I'm trying to use yacc learning/reading the sun manual
> and I'm not getting anywhere.  Please, if you can send me a yacc grammar
> that you wrote I would really appreciate it.  

   Check your bookstore. I found one of the Nutshell books that covers
yacc and lex. (This was in the Stanford Bookstore -- the kind of place
that makes you think you have died and gone to computer heaven.)