John
John

Reputation: 55

creating automata in java

How can I create such program in Java that could accept automata regular expression and a minimum string length (int) and generate possible Strings?

examples of regular regular expressions are

regex             possible strings
(a+b)*            abbababababbbab
ab(a+b)           ababababab, abaaaa, abbbbb, abbaba, . . .

Upvotes: 1

Views: 1298

Answers (2)

matt freake
matt freake

Reputation: 5090

This library mentioned in this post (which generates a random, matching string, I believe) maybe of use

Using Regex to generate Strings rather than match them

Upvotes: 0

aioobe
aioobe

Reputation: 421220

  1. Compile an automaton (standard automata text book exercise)
  2. Simulate the automaton by walking along the edges recording which symbols you use (branching into parallel simulations if needed)
  3. Output the current string each time you reach an accepting state.

Upvotes: 2

Related Questions