Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grammer Tester #141

Open
Moondee opened this issue Sep 2, 2014 · 5 comments
Open

Grammer Tester #141

Moondee opened this issue Sep 2, 2014 · 5 comments

Comments

@Moondee
Copy link

Moondee commented Sep 2, 2014

Is it possible that given a PEG grammar, generate a random string that satisfies the given grammar and then test this string?

@PhilippeSigaud
Copy link
Collaborator

Pegged cannot produce the language a grammar defines, if that is what you
mean.

@Moondee
Copy link
Author

Moondee commented Sep 2, 2014

What I meant was suppose we have a grammar for a calculator.
Can Pegged generate valid sequences for the calculator grammar? like randomly generate ' 1+2'...

@PhilippeSigaud
Copy link
Collaborator

What I meant was suppose we have a grammar for a calculator.
Can Pegged generate valid sequences for the calculator grammar? like
randomly generate ' 1+2'...

No, it cannot.

Hmm, I don't know of a parser generator doing that, even though grammars
are supposed to be generative in nature (that is, used to produce
sentences, not to parse them).

You know, even for small languages, I don't think that would be that
interesting: most of the generated strings would be useless ("1", "2",
"11", ..., not even reaching a '+' part), unless it iterates the grammar in
a breadth-first way. And that's not even taking white spaces into account.
'Most' of the sentences thus generated would be far too simple to be of any
use, in case you were thinking about generating programs from a programming
language grammar.

@Moondee
Copy link
Author

Moondee commented Sep 3, 2014

Thanks. I agree. Surprisingly I see several string generators for CFG like Yagg , DGL,..., though have't seen any for PEG based language.

@PhilippeSigaud
Copy link
Collaborator

Thanks. I agree. Surprisingly I see several string generators for CFG like
Yagg , DGL,..., though have't seen any for PEG based language.

Do you know what people use them for? To verify the grammar they wrote
indeed generates the right language?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants