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

Allow to add annotations to Cfg elements #889

Open
jenetics opened this issue Oct 9, 2023 · 0 comments
Open

Allow to add annotations to Cfg elements #889

jenetics opened this issue Oct 9, 2023 · 0 comments
Assignees

Comments

@jenetics
Copy link
Owner

jenetics commented Oct 9, 2023

It should be possible to add annotations to all Cfg elements like Cfg.Rule, Cfg.Terminal or Cfg.NonTerminal. This annotations can than be used to influence the program generation from an CFG. Such an annotation could be a weight for a given element, which is than be used to influence the selection probability during program generation.

Example
A BNF representation might look like this:

<expr> ::= <num> | <var> @weight=4 | '(' <expr> <op> <expr> ')' @weight=5
<op>   ::= + | - | * | /
<var>  ::= x | y
<num>  ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

In this example, the <num> rule would have a selection probability of 1/10 and the <var> rule of 4/10.

With such annotation it will be possible to generate programs with the desired properties much easier.

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

1 participant