[antlr-interest] Build grammar automatically?

Johannes Luber jaluber at gmx.de
Mon Oct 27 04:22:20 PDT 2008


Dennis Yurichev schrieb:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Hi!
> 
> Sorry if my question is not suitable for this list.
> 
> Let's say I have a huge text files written on *some*programming*language*.
> It is possible somehow to build grammar automatically from these texts?
> Theoretically, these texts represent all possible language constructs in
> various forms.
> It will be OK if output grammar be in need of some rework.
> So, is there anything usable?

Sounds like machine learning. I don't know if one can actually create
grammars via the use of such a special program or if one can, if you
really manage to get a large enough sample to derive the correct
structures (after all, every language has some obscure constructs). I
can imagine that the machine-created grammar allows disallowed
constructs and disallows allowed constructs and you have to find those
cases. But even if you get a working grammar out of it, it won't be
actually human-readable because the rules don't have sensible names.

Anyways, ANTLR isn't suitable for this task, but may be actually faster
to create grammars than your proposal as the rework is in part doing
things, which one would do using ANTLR. In fact, starting with an
official grammar is far easier than inventing your own.

Johannes
> 
> - --
> My PGP public key: http://yurichev.com/dennis.yurichev.asc
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.8 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iEYEARECAAYFAkkFfJ0ACgkQ1YPmFmJG++N5lgCfdygGPsgLJjkTXtSz3w3q0W82
> 0KIAnj1gpx+vp9sQC2UieRT6W1ra0iKP
> =nWUX
> -----END PGP SIGNATURE-----
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address
> 



More information about the antlr-interest mailing list