On parsers using Mosml ML
The Moscow ML distribution contains tools lex and yacc like tools (called mosmllex and mosmlyacc) for the generation of lexers and parsers. These tools are documented in
Moscow ML Owner's Manual, which is found on the Moscow ML homepage.
Illustrative example are found in the following directory of the Moscow ML distribution:
mosml/examples/lexyacc.
The below files, which are revised extracts of files from the distribution, can be used for scanning and parsing the simple while-language, which has been introduced in the lecture:
- Absyn.sml:
Abstract syntax for a imperative language.
- Interpreter.sml:
A skeleton program for an interpreter for the a imperative language.
- Factorial.while:
Sample program, which can be parsed.
- WHILElex.lex:
Input to mosmllex.
- WHILEpar.grm:
Input to mosmlyac.
- parse.sml:
File containing functions to parse programs. You do not have to change
this file solving the exercises. You only have to use the function parses:
string -> stm (parses a statement from a string) and the function
parsef: string -> stm, which parses a statement from a file.
- You can see how to compile the above files here.
Last update: Octoberber 11, 2007, Michael R. Hansen