| 1 |
fol/README |
| 2 |
|
| 3 |
This is a sample parser for first-order logic. The grammar |
| 4 |
was contributed by Frank Pfenning. |
| 5 |
|
| 6 |
The parser is defined by the files |
| 7 |
|
| 8 |
fol.lex (* defines lexer *) |
| 9 |
fol.grm (* defines grammar *) |
| 10 |
link.sml (* constructs basic parser structures *) |
| 11 |
absyn.sml (* a trivial abstract syntax *) |
| 12 |
interface.sml (* interface to lexer and parser properties *) |
| 13 |
parse.sml (* driver functions *) |
| 14 |
fol.mlb (* ML Basis file *) |
| 15 |
|
| 16 |
To compile this example, type the following commands |
| 17 |
|
| 18 |
mllex fol.lex |
| 19 |
mlyacc fol.grm |
| 20 |
mlton fol.mlb |
| 21 |
|
| 22 |
in this directory. They will invoke ml-lex and ml-yacc to process the |
| 23 |
lexer specification fol.lex and the grammar specification fol.grm |
| 24 |
respectively. Then they will compile the resulting SML source files |
| 25 |
|
| 26 |
fol.lex.sml |
| 27 |
fol.grm.sig |
| 28 |
fol.grm.sml |
| 29 |
|
| 30 |
and the other sml source files. |
| 31 |
|
| 32 |
The end result of loading these files is a structure Parse containing |
| 33 |
the following top-level driver functions: |
| 34 |
|
| 35 |
val prog_parse : string -> Absyn.absyn |
| 36 |
(* parse a program from a string *) |
| 37 |
|
| 38 |
val query_parse : string -> Absyn.absyn |
| 39 |
(* parse a query from a string *) |
| 40 |
|
| 41 |
val file_parse : string -> Absyn.absyn |
| 42 |
(* parse a program in a file *) |
| 43 |
|
| 44 |
val top_parse : unit -> Absyn.absyn |
| 45 |
(* parse a query from the standard input *) |
| 46 |
|
| 47 |
|
| 48 |
The file list.fol is a sample input file that can be parsed using |
| 49 |
the file_parse function: |
| 50 |
|
| 51 |
- Parse.file_parse "list.fol"; |
| 52 |
|
| 53 |
|
| 54 |
NOTE: The ML Basis file fol.mlb mentions the ml-yacc library |
| 55 |
(mlyacc-lib.mlb). MLton's search path should be configured so that this |
| 56 |
library will be found. This should normally be the case if MLton is |
| 57 |
properly installed. |