I am a beginner in OCaml and trying to build a parser, I want to have a list that stores all the methods in my class. This is one part that I have in my .mly file.
init_method_list:
{ [] }
| method_list method_decl { List.rev($1) }
;
method_list:
method_decl { [ $1 ] }
| method_list method_decl { $2 :: $1 }
;
Can anyone explain exactly what's going on here? Especially the :: operation. Been googling around but couldn't find the operator in the docs.
I get that the list can be empty, or we make right recursive calls to fill it up with all the methods in class. method_decl
just looks for the match of the specific token combinations that represents a method.