added type grammar to readme, add example, del spho loc
This commit is contained in:
parent
a22c9726cd
commit
7e3c7c88ea
3 changed files with 47 additions and 35 deletions
25
README.md
25
README.md
|
@ -1 +1,26 @@
|
||||||
# log-e-sappho
|
# log-e-sappho
|
||||||
|
|
||||||
|
experimental type system implementation
|
||||||
|
|
||||||
|
## sappho grammar
|
||||||
|
|
||||||
|
```
|
||||||
|
s, t ::= s | t (disjunction, a.k.a. union)
|
||||||
|
| s & t (conjunction, a.k.a. intersection)
|
||||||
|
| s => t (implication)
|
||||||
|
| s -> t (arrow, a.k.a. function)
|
||||||
|
| forall x . t (forall, polymorphic)
|
||||||
|
| box t (box, modular logic)
|
||||||
|
| a [t..] (type operator application)
|
||||||
|
| x (variable)
|
||||||
|
| n (nominal)
|
||||||
|
| true (true, a.k.a. top)
|
||||||
|
| false (false, a.k.a. bottom)
|
||||||
|
| { m : t } (member, a.k.a. atomic record)
|
||||||
|
|
||||||
|
|
||||||
|
x ∈ var
|
||||||
|
n ∈ nominal
|
||||||
|
a ∈ opname
|
||||||
|
```
|
||||||
|
|
||||||
|
|
21
example/ex5.msph
Normal file
21
example/ex5.msph
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
nominal N
|
||||||
|
nominal M
|
||||||
|
|
||||||
|
|
||||||
|
type T[X, Y] = {
|
||||||
|
// body
|
||||||
|
}
|
||||||
|
|
||||||
|
type A = T[N, M] // binding X -> N, Y -> M
|
||||||
|
type B = T[M, N] // binding X -> M, Y -> N
|
||||||
|
|
||||||
|
// converted to
|
||||||
|
|
||||||
|
type A = ⟨ X -> N, Y -> M ⟩ {
|
||||||
|
// body
|
||||||
|
}
|
||||||
|
type B = ⟨ X -> M, Y -> N ⟩ {
|
||||||
|
// body
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
#ifndef _SPHO_LOC_H
|
|
||||||
#define _SPHO_LOC_H
|
|
||||||
|
|
||||||
#define SPHO_LOCTYPE_LINE 1
|
|
||||||
#define SPHO_LOCTYPE_LINE_COL 2
|
|
||||||
|
|
||||||
|
|
||||||
struct spho_loc_line {
|
|
||||||
char *fpath;
|
|
||||||
unsigned int lineno;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct spho_loc_line {
|
|
||||||
char *fpath;
|
|
||||||
unsigned int lineno;
|
|
||||||
unsigned int colno;
|
|
||||||
};
|
|
||||||
|
|
||||||
union spho_loc_info {
|
|
||||||
struct spho_loc_line line;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct spho_loc {
|
|
||||||
struct spho_ctx *ctx;
|
|
||||||
int loctype;
|
|
||||||
union spho_loc_info locinfo;
|
|
||||||
};
|
|
||||||
|
|
||||||
char *spho_loc_str(struct spho_loc *);
|
|
||||||
struct spho_loc *spho_loc_create_line(struct spho_ctx *, char *, int);
|
|
||||||
struct spho_loc *spho_loc_create_linecol(struct spho_ctx *, char *, int, int);
|
|
||||||
void spho_loc_destroy(struct spho_loc *);
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Add table
Add a link
Reference in a new issue