I am a complete newbie at this and may be my question is stupid, I apologize in advance. I want to convert any piece of code to BNF form.
https://en.wikipedia.org/wiki/Backus%E2%80%93Naur_form
For example, here is some code (code can be completely different)
m = NULL
for(i in 1:10){
m[i] = i
}
I want to get something like this
<expr> ::= <var><equ><null> ;
for(<iter> in <vec>) {
<var><br><equ><iter>}
<var> ::= m
<equ> ::= =
<br> ::= [i]
<vec> ::= 1:10
<iter> ::= i
<null> ::= NULL
There may be errors in my BNF form, take this as an illustration of what I would like to receive, and not as an exact example
I would like to get an example of how this is generally done
===== upd =====
I'm using grammatical evolution gramEvol package to find useful expressions (R code)
features of this package
- takes the BNF form as input
- generates different expressions
- checks expressions against the fitness function
I would like to be able to generate the BNF for this package from my relatively small chunks of real R code.