0

I want to generate some random data for tests based on a given EBNF grammar. The different tools that exist on the internet are oriented SQL queries, but I want to have different kind of data.

It seems that Antlr could do that, but I don't know how, because I know that it could be used just as a recognizer or translator...

Thank you in advance for your help

1 Answers1

1

ANTLR 3 has a RandomPhrase class that you could look at. It's not optimal but the basic idea is to choose random paths when you get to a decision point, a list of alternatives in a rule.

Terence Parr
  • 5,912
  • 26
  • 32
  • Thanks The ANTLR Guy, it dosn't work perfectly but I am trying to modify the code a little bit. Another problem, there is no enough documentation – Zakaria Jaiathe Mar 11 '14 at 08:54
  • Yeah, sorry about that. It turns out that just randomly picking up half doesn't work out too well. I would look at the ATN data structures in v4 as those are better documented and cleaner. It comes down to just a depth first search where you take only one path at each decision point, randomly. – Terence Parr Mar 11 '14 at 17:31
  • Ok thank you very much, I will try also the v4 even if I want to be on the same version as my team. – Zakaria Jaiathe Mar 12 '14 at 10:38