Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!solo.csci.unt.edu!ponder!cluther From: cluther@ponder.csci.unt.edu (Clay Luther) Newsgroups: comp.unix.wizards Subject: Writing a simple sentence parser in lex/yacc Message-ID: Date: 22 May 91 23:18:52 GMT Sender: usenet@solo.csci.unt.edu (Usenet News) Organization: University of North Texas, Denton Lines: 38 Hello All: I recently found a need to learn and use lex/yacc. I have purchased the nutshell book, but I find it somewhat lacking. I don't know if it's me or what. Anyway, I though I would turn to here for some advice. I need to create a sentence parser. Right now, it only needs to be very simple. Here is a sketchy grammer for the language. sentences :== sentences sentence sentence :== verbphrase prepphrase verbphrase :== verb | verb object prepphrase :== prep object | EMPTY verb :== word prep :== "with" | "in" | "on" | "about" object :== word | words | string string :== "\"" words "\"" words :== words word | word word :== [a-zA-Z]+ It should parse as follows: throw ball - verb = throw, verb object = ball throw ball with "blue stripes" - verb throw, vo ball, prep with, po "blue stripes" throw blue ball with white stripes - v throw, vo blue ball, p with, po white stripes I cannot seem to create a yacc/lex definition for this. Any help is *greatly* appreciated. Thanks. -- Clay Luther Lonely C++ Programmer cluther@ponder.csci.unt.edu cluther@solo.csci.unt.edu I work here now and they still cluther@supernet.haus.com don't let me have any opinions.