Click here to Skip to main content
15,117,318 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how i do statement from grammer in c++ ??

grammer :

<s> -> <a> a <b> b | d
<a> -> <a> b | b
<b> -> a <b> | a

build statement :

1- d
2- baab
3- bbaaab

thank you

[edit]Code block added to preserve HTML tags - OriginalGriff[/edit]
[edit]Auto encoder missed the <b> "tags" manually fixed - OriginalGriff[/edit]
Updated 6-Nov-14 5:56am
OriginalGriff 6-Nov-14 10:48am
What have you tried?
Where are you stuck?
What help do you need?
Albert Holguin 6-Nov-14 11:52am
Your question is not clear.
emm_a 6-Nov-14 12:46pm
I want the program build random statement from grammer
Richard MacCutchan 6-Nov-14 13:30pm
You need to write a parser. Google will find you many samples and libraries that you can use to help you.
emm_a 6-Nov-14 14:03pm
Yes I need write parser
I search in google but I did not find
help me please
thank you
Rob Grainger 7-Nov-14 11:48am
That's way beyond the scope here. Way, way, way beyond the scope. There are entire books on the subject. Searching for "Parser" on Wikipedia may help. Or indeed "Parser" in Google (you evidently didn't try very hard).

But, if you're trying to go from a grammar to random statements, that's more generative use of a grammar. An entirely different subject. Search for "Generative Grammar".

Be prepared to spend a month or so reading ;-)
emm_a 15-Nov-14 14:47pm
Thank you for all

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900