[Tools-discuss] Eustathius, a program to generate texts from formal grammars
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tools-discuss] Eustathius, a program to generate texts from formal grammars



It may have a place in http://tools.ietf.org/inventory/verif-tools?

http://www.bortzmeyer.org/eustathius-test-grammars.html

Eustathius is a set of programs to test ABNF grammars by parsing them 
and generating texts which obey the grammar.

You can use it to test ABNF in documents like the RFC or to test a 
parser that you have written.

Eustathius can be downloaded (en ligne sur 
http://www.bortzmeyer.org/files/eustathius.tar.gz). It will require an 
Haskell compiler to build.

You are free to use it, accoding to the GPL.

Here is a sample grammar (you can find many others, typically extracted 
from the RFCs in the tests/ directory of the distribution) of a 
Lisp-like programming language:

program = expr

expr = spaces "(" spaces *(expr / term ) spaces ")" spaces

term = 1*ALPHA

spaces = *WSP

And here is the result of parsing with
abnf-parse, a program of Eustathius:


% ./abnf-parse tests/minilisp.abnf
program : expr
expr : Seq[spaces ( spaces 0*10Choice[expr term] spaces ) spaces]
term : 1*10ALPHA
spaces : 0*10WSP
...
All the rules:
expr:  (UNsafe)
term:  (Safe)
...
 (Safe are the rules for which there is at least a terminal in
the next N steps.)

After that, you can use Eustathius to generate sample programs, for 
instance to give them to your parser:

% ./abnf-generate -s program tests/minilisp.abnf
(        (      eWbejp   (  )(   kwMRMhvamEcGMLTDWGhTlooAXHQmzmwYiqEMn
)       erDZ)LXfhB ()ZtkatUFlSZ         (yrKg    (daaLeuAxXFGZq)
) (ObMi(y       )  CoqZBW(qET  )                )               )  


Remember that the ABNF grammar only describes the syntax. Some semantic 
rules are not, or cannot be expressed in the grammar and therefore, 
Eustathius can produce texts which are not legal. For instance, in RFC 
3339, you find a grammar to generate dates and it does not protect 
against months > 12, so Eustathius can do:

 % ./abnf-generate -s date tests/date.abnf
2679-73-08


Thanks to Kim-Minh Kaplan (http://www.kim-minh.com/) for his help and 
the discussions.


_______________________________________________
Tools-discuss mailing list
Tools-discuss at ietf.org
https://www1.ietf.org/mailman/listinfo/tools-discuss




Note: Messages sent to this list are the opinions of the senders and do not imply endorsement by the IETF.