define the block like this
compound_stat
= '{' decl exp_stat '}'
exp_stat
= exp ';'
decl
= decl_specs id ';'
decl_specs
= 'int'/'float'
id
=name:[a-z]+ {return name.join("");}
exp_stat
= left:multiplicative "+" right:exp_stat { right=right+1;return left + right; }
/ multiplicative
multiplicative
= left:primary "*" right:multiplicative { return left * right; }
/ primary
primary
= integer
/id
/ "(" exp_stat:exp_stat ")" { return exp_stat; }
integer "integer"
= digits:[0-9]+ { return parseInt(digits.join(""), 10); }
want to achieve that {float a =3;a*3+1;} return 10 i don't know how to reference the id in two statements which are "decl" and "exp_stat". who can share an example?