Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better readme and other improvements
- Loading branch information
1 parent
4c34b3b
commit bb868ec
Showing
7 changed files
with
57 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,17 +1,21 @@ | |||
(* Contexts *) | (** Handling of contexts. | ||
let lookup = List.assoc | |||
A context is represented as an associative list which maps a variable [x] | |||
to a pair [(t,e)] where [t] is its type and [e] is its value (optional). | |||
*) | |||
|
|
||
let index x ctx = | let lookup = List.assoc | ||
let rec index k = function | |||
| [] -> raise Not_found | |||
| y :: ys -> if x = y then k else index (k+1) ys | |||
in | |||
index 0 ctx | |||
|
|
||
(** [lookup_ty x ctx] returns the type of [x] in context [ctx]. *) | |||
let lookup_ty x ctx = fst (lookup x ctx) | let lookup_ty x ctx = fst (lookup x ctx) | ||
|
|
||
(** [lookup_ty x ctx] returns the value of [x] in context [ctx], or [None] | |||
if [x] has no assigned value. *) | |||
let lookup_value x ctx = snd (lookup x ctx) | let lookup_value x ctx = snd (lookup x ctx) | ||
|
|
||
(** [extend x t ctx] returns [ctx] extended with variable [x] of type [t], | |||
whereas [extend x t ~value:e ctx] returns [ctx] extended with variable [x] | |||
of type [t] and assigned value [e]. *) | |||
let extend x t ?value ctx = (x, (t, value)) :: ctx | let extend x t ?value ctx = (x, (t, value)) :: ctx | ||
|
|
||
|
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,4 +1,6 @@ | |||
{ | { | ||
(** The lexer. *) | |||
|
|||
open Parser | open Parser | ||
|
|
||
let reserved = [ | let reserved = [ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
Syntax | |||
Error | |||
Ctx | |||
Infer | |||
Tt | |||
Beautify | |||
|
|||
|