Join GitHub today
The Parse Tree (AST)
This section gives an overview of the files in the parsing directory of the OCaml repo.
As explained in the Source code section, an
.mly file is used to generate a parser for a specified grammar.
parsing/parser.mly has the full specification of the grammar.
The file is well commented (if not, contribute, or edit this page!) but this is a quick rundown of the main features of the AST.
constant: integer, character, string and float literals.
attribute: attributes are “decorations” of the syntax tree which are mostly ignored by the type-checker but can be used by external tools and are made of an identifier and a payload (any unrecognised ones are ignored)
extension: extensions are generic placeholders in the syntax tree - rejected by the type-checker and are intended to be “expanded” by external tools such as -ppx rewriters.
payload: contents of an
extension- a structure, signature, type or a pattern.
Now we get into the core language expressions [incomplete].