Skip to content

Commit 9501115

Browse files
Data milestone 2 (#33)
Global const data works. Using Fir, Oir, Scir to do main compilation. Some lint refactoring was done to handle scopes better. Scopes and Type Tables will need a significant refactor
1 parent a40bec7 commit 9501115

File tree

27 files changed

+790
-404
lines changed

27 files changed

+790
-404
lines changed

Cargo.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ members = [
1111
"ast",
1212
"project",
1313
"ty",
14-
"ir",
1514
"e2e",
1615
"tyvm",
17-
"linter",
16+
"linter",
1817
"codelocation",
19-
"types",
20-
"cachectx",
21-
"typetable",
22-
"scopetable"
23-
]
18+
"types",
19+
"typetable",
20+
"scopetable",
21+
"fir",
22+
"oir",
23+
"scir",
24+
"datatable",
25+
]
2426
resolver = "2"
2527

bootstrap/token/lib.ty

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pub type TokenError = error
22
| InvalidToken
33
| UnexpectedEnd
44

5-
pub type Token = enum(u8) {
5+
pub type Token = enum
66
| Error
77
| Defer
88
| ErrDefer

cachectx/Cargo.toml

Lines changed: 0 additions & 17 deletions
This file was deleted.

cachectx/src/lib.rs

Lines changed: 0 additions & 57 deletions
This file was deleted.

datatable/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "datatable"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]
7+
cranelift-module = "0"

datatable/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use cranelift_module::DataId;
2+
use std::collections::BTreeMap;
3+
4+
pub struct DataTable {
5+
pub table: BTreeMap<String, DataId>,
6+
}
7+
8+
impl DataTable {
9+
pub fn new() -> Self {
10+
DataTable {
11+
table: BTreeMap::new(),
12+
}
13+
}
14+
}

e2e/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ typetable = { path = "../typetable" }
1212
lexer = { path = "../lexer" }
1313
token = { path = "../token" }
1414
parser = { path = "../parser" }
15-
ir = { path = "../ir" }
1615
object = { path = "../object" }
1716
objmaker = { path = "../objmaker" }
1817
linter = { path = "../linter" }

e2e/src/main.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@ use linter::LintSource;
44
use parser::Parser;
55
use std::fs::File;
66
use std::io::Read;
7-
use typetable::TypeTable;
87

98
use std::path::Path;
109
use std::process::Command;
1110

1211
fn main() {
1312
println!("[run] simple exe");
1413
objmaker::from_buffer(
15-
"pub const main = fn() usize {
16-
const m = 7
14+
"const m = 7
15+
pub const main = fn() usize {
1716
const x = 5
18-
return x + m
17+
return x + m
1918
}",
2019
Path::new("main.ty"),
2120
);

ebnf.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// use this to test, and this must pass at all times
22
// https://bnfplayground.pauliankline.com/
33
<all> ::= (<top_decl>)*
4-
<top_decl> ::= "pub "? ("const " | "let " | "type " | "impl ") <ident> (":" <signature>)? " = " (<trait> | <fn> | <struct> | <tag> | <import> | <error> | <reassign> | <expr> | <enum>)
4+
<top_decl> ::= "pub "? ("const " | "let " | "type " | "impl ") <destructure> (":" <signature>)? " = " (<trait> | <fn> | <struct> | <tag> | <import> | <error> | <reassign> | <expr> | <enum>)
55
<import> ::= "import " <chars>
6-
<trait> ::= "trait " "{ " (<top_decl)* " }"
6+
<trait> ::= "trait " "{ " (<top_decl>)* " }"
77
<signature> ::= <val_type> | ("&" | "*")? ("[" <signature> "]" | <ident> ("." <ident>)* | <fn_type>)
88
<fn_type> ::= "fn" "(" <type_args> ")" ("void" | <signature>)
99
<type_args> ::= (<type_arg> ("," <type_arg>)*)?
@@ -15,14 +15,15 @@
1515
<for> ::= "for " "(" <expr> ")" (<fn> | <block>)
1616
<while> ::= "while " "(" <expr> ")" (<fn> | <block>)
1717
<match> ::= "match " "(" <expr> ")" "{ " <arm>+ "}"
18-
<arm> ::= <expr> "=> " (<fn> | <block>)
18+
<arm> ::= <expr> "=> " (<fn> | <block> | <or>)
1919
<tag> ::= "tag " ("| " <ident> (":" <signature>)?)+
2020
<enum> ::= "enum" "(" <val_type> ")" ("| " <ident> ("=" <expr>)?)+
2121
<declarators> ::= (<declarator>)*
2222
<declarator> ::= "pub "? <ident> (":" <signature>)?
23+
<destructure> ::= ("{ " <ident> ("," <ident>)* " }") | <ident>
2324
<args> ::= (<arg> ("," <arg>)*)?
2425
<arg> ::= ("self " (": " <signature>)?) | <ident> (":" <signature>)?
25-
<inner_decl> ::= ( "const " | "let ") <ident> (":" <signature>)? "= " <expr>
26+
<inner_decl> ::= ( "const " | "let ") <destructure> (":" <signature>)? "= " <expr>
2627
<reassign> ::= <access> ("= " <expr>)?
2728
<block> ::= "{ " (<inner_decl> | <for> | <while> | <if> | <reassign>)* (<return> | <break>)? "}"
2829
<return> ::= "return " <expr>?
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
[package]
2-
name = "ir"
2+
name = "fir"
33
version = "0.1.0"
44
edition = "2021"
55

6-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7-
86
[dependencies]
97
ast = { path="../ast" }
8+
oir = { path="../oir" }
109
symtable = { path="../symtable" }
10+
datatable = { path="../datatable" }
1111
typetable = { path="../typetable" }
12+
scopetable = { path="../scopetable" }
1213
token = { path="../token" }
1314
perror = { path="../perror" }
1415
lexer = { path="../lexer" }
1516
linter = { path="../linter" }
1617
types = { path="../types" }
1718
cranelift-frontend = "0"
1819
cranelift-codegen = "0"
20+
cranelift-module = "0"

0 commit comments

Comments
 (0)