English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Testing lexers and parsers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-02-27 (15:29)
From: Joel Reymont <joelr1@g...>
Subject: Testing lexers and parsers

I'm trying to incrementally develop a translator using a test-driven  
approach. I figure I can write a bunch of tests for small chunks of  
functionality to structurally test expected AST against produced.

Once I get to testing the parsing of whole files I think I can print  
the AST I produce into a file and test this against a target file  
with the correct printed AST. I can probably run 'cmp' to make sure  
my files match. This would not be a structural comparison, though,  
and would be highly dependent on white space which does not strike me  
as ideal.

Is there a better way to accomplish this while still using structural  
comparison of ASTs?

Should I try to read my target AST into OCaml, for example? Should I  
create a bunch of "target AST" modules with functions that return my  
target AST?

How does everyone else approach testing of lexers and parsers?

	Thanks, Joel