having built something similar for antlr in the old days, I can also point out 
that it’s extremely challenging deciding whether to loop/recurse when faced 
with a decision. It’s hard to determine what the right choices to generate 
reasonably sized input. I ended up with extremely short or extremely long input 
sometimes.

Ter
On Sep 5, 2014, at 12:06 PM, mathew palsberg <matpalsb...@gmail.com> wrote:

> Thanks Lukas, and agree generating strings considering lookahead and ! should 
> be very hard!
> I dont know how one could generate valid string according to NOT and 
> Lookaheads.
> cheers.
> 
> 
> On Fri, Sep 5, 2014 at 7:23 AM, Lukas Renggli <reng...@gmail.com> wrote:
> The PetitParser UI [1] has the capability to display random examples of a 
> selected production. Unfortunately the UI (and the example generating code) 
> is only available in Smalltalk and hasn't been ported to other host 
> languages. However, you can look at the code here [2] and play with the tool 
> by downloading the one-click distribution [3]. 
> 
> The example generating code is really short and simple (less than 30 lines, 
> the rest is markup from the export). There are a few (hardcoded) heuristics 
> to make it produce a short and readable example.
> 
> Note that the code ignores logical predicates (! and & expressions). I am not 
> sure, if it is even possible to make them work in a generic case? Either way, 
> I found that ignoring the predicates isn't as bad as it sounds. Predicates 
> are rarely used in practice and do have a big effect on the resulting output 
> (as long as you are aware of it).
> 
> To summarise, I find the examples quite useful while developing new grammars. 
> It allows one to quickly spot errors or edge-cases that might get missed 
> otherwise.
> 
> Cheers,
> Lukas
> 
> [1] http://scg.unibe.ch/archive/papers/Reng10cDynamicGrammars.pdf (Section 
> 3.5)
> [2] 
> http://www.lukas-renggli.ch/dropbox/petitparser/libraries/PetitParser-Example.st
> [3] http://source.lukas-renggli.ch/built/oneclick/PetitParser-OneClick.zip
> 
> 
> On 4 September 2014 19:54, mathew palsberg <matpalsb...@gmail.com> wrote:
> Hello,
> I recently built a small language with PEG. I now want to test my language 
> with random generated(not necessarily meaningful) programs. Does anybody know 
> a tool that given a PEG grammar, it generates random sequences that satisfy 
> the given grammar?
> 
> Thanks;
> 
> 
> _______________________________________________
> PEG mailing list
> PEG@lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/peg
> 
> 
> 
> 
> -- 
> Lukas Renggli
> www.lukas-renggli.ch
> 
> _______________________________________________
> PEG mailing list
> PEG@lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/peg


_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to