Lexical/Syntax analyzer
-
- AST definition
-
- Defines a token for lexing
-
- Defines a grammar for parsing
-
- Parser
https://discuss.ocaml.org/t/generate-a-parser-enabling-incremental-api-and-inspection-api/9380/2
menhir --explain --inspection --table --dump --infer-write-query mockfile.ml parser.mly
# to generate mockfile.ml
ocamlfind ocamlc -I . -I src syntax.ml -c -o syntax.cmi
ocamlfind ocamlc -I lib -package menhirLib -i mockfile.ml > sigfile
# to generate sigfile. Note that -I lib refers to the directory of external modules, their .cm[io] files should be ready to use.
menhir --explain --inspection --table --dump --infer-read-reply sigfile parser.mly
# to generate especially parser_e.ml, parser_e.mli, .conflicts and automaton.
rm mockfile.ml
rm parser.automaton
rm parser.conflicts
rm parser.mli
rm sigfile
rm syntax.cmi
rm syntax.cmo