Hi!

* Daniel Carrera:
> On Fri, Jan 23, 2004 at 06:08:37AM +0900, Mauricio Ferna'ndez wrote:
> Where can I learn how to make good parsers?

There are a couple of books. A good one in english is

TI   lex & yacc
AU   JohnR. LEVINE, Tony MASON, Dough BROWN
ISBN 1-56592-000-7

It deals with lex (a Lexer) and yacc (Yet Another Compiler Compiler).
There is also a book in german by Helmut Herold with the same title,
ISBN is 3-8273-2096-8. By using them you not only learn the art
itself but also two nice tools.

But you do not necessarily have to go through that. It would be
enough to learn using EBNF:

<time>    ::= <product> (('+' | ',') <product>)*
<product> ::= (<digit> '*')* <period>>
<period>  ::= <months> | <weeks> | <days> | <hours> | <mins> | <secs>
<months>  ::= <number> 'month' 's'?
<weeks>   ::= <number> 'w' ('eek' 's'?)?
<days>    ::= <number> 'd' ('ay' 's'?)?
<hours>   ::= <number> 'h' ('our' 's'?)?
<mins>    ::= <number> 'm' ('in' ('ute')? 's'?)?
<secs>    ::= <number> ('s' ('ec' ('ond')? 's'?)?)?

Take a look at the 'Parsing periods of time: Code and questions'
thread - implementation of <number> is left to Ruby.

Josef 'Jupp' SCHUGT
-- 
http://oss.erdfunkstelle.de/ruby/    -     German comp.lang.ruby-FAQ
http://rubyforge.org/users/jupp/     -     Ruby projects at Rubyforge
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Germany 2004: To boldly spy where no GESTAPO / STASI has spied before