I wonder what is the language used in the curly braces of the rule section in yacc/bison files like the following and if there is any good reference about it.
stmts : stmt { $$ = new NBlock(); $$->statements.push_back($<stmt>1); }
| stmts stmt { $1->statements.push_back($<stmt>2); }
;
and in the above code, for example, why it is written $<stmt>$2
not just $2
It's actually C code with a custom macro preprocessor.
yacc/bison replaces all occurence of $$ with C code that refers to the semantic value of the rule's target component, and $n with the semantic value of rule element #n.
The code is actually C (and by extension, C++), and $$ and $n get replaced by bison itself, with C code that refers to the rule target's, or rule element's semantic value.
See this chapter of bison's documentation for more information.