Skip to content

Commit

Permalink
Data milestone 2 (#33)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
coffeebe4code authored Dec 24, 2024
1 parent a40bec7 commit 9501115
Show file tree
Hide file tree
Showing 27 changed files with 790 additions and 404 deletions.
16 changes: 9 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ members = [
"ast",
"project",
"ty",
"ir",
"e2e",
"tyvm",
"linter",
"linter",
"codelocation",
"types",
"cachectx",
"typetable",
"scopetable"
]
"types",
"typetable",
"scopetable",
"fir",
"oir",
"scir",
"datatable",
]
resolver = "2"

2 changes: 1 addition & 1 deletion bootstrap/token/lib.ty
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub type TokenError = error
| InvalidToken
| UnexpectedEnd

pub type Token = enum(u8) {
pub type Token = enum
| Error
| Defer
| ErrDefer
Expand Down
17 changes: 0 additions & 17 deletions cachectx/Cargo.toml

This file was deleted.

57 changes: 0 additions & 57 deletions cachectx/src/lib.rs

This file was deleted.

7 changes: 7 additions & 0 deletions datatable/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "datatable"
version = "0.1.0"
edition = "2021"

[dependencies]
cranelift-module = "0"
14 changes: 14 additions & 0 deletions datatable/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
use cranelift_module::DataId;
use std::collections::BTreeMap;

pub struct DataTable {
pub table: BTreeMap<String, DataId>,
}

impl DataTable {
pub fn new() -> Self {
DataTable {
table: BTreeMap::new(),
}
}
}
1 change: 0 additions & 1 deletion e2e/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ typetable = { path = "../typetable" }
lexer = { path = "../lexer" }
token = { path = "../token" }
parser = { path = "../parser" }
ir = { path = "../ir" }
object = { path = "../object" }
objmaker = { path = "../objmaker" }
linter = { path = "../linter" }
7 changes: 3 additions & 4 deletions e2e/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ use linter::LintSource;
use parser::Parser;
use std::fs::File;
use std::io::Read;
use typetable::TypeTable;

use std::path::Path;
use std::process::Command;

fn main() {
println!("[run] simple exe");
objmaker::from_buffer(
"pub const main = fn() usize {
const m = 7
"const m = 7
pub const main = fn() usize {
const x = 5
return x + m
return x + m
}",
Path::new("main.ty"),
);
Expand Down
9 changes: 5 additions & 4 deletions ebnf.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// use this to test, and this must pass at all times
// https://bnfplayground.pauliankline.com/
<all> ::= (<top_decl>)*
<top_decl> ::= "pub "? ("const " | "let " | "type " | "impl ") <ident> (":" <signature>)? " = " (<trait> | <fn> | <struct> | <tag> | <import> | <error> | <reassign> | <expr> | <enum>)
<top_decl> ::= "pub "? ("const " | "let " | "type " | "impl ") <destructure> (":" <signature>)? " = " (<trait> | <fn> | <struct> | <tag> | <import> | <error> | <reassign> | <expr> | <enum>)
<import> ::= "import " <chars>
<trait> ::= "trait " "{ " (<top_decl)* " }"
<trait> ::= "trait " "{ " (<top_decl>)* " }"
<signature> ::= <val_type> | ("&" | "*")? ("[" <signature> "]" | <ident> ("." <ident>)* | <fn_type>)
<fn_type> ::= "fn" "(" <type_args> ")" ("void" | <signature>)
<type_args> ::= (<type_arg> ("," <type_arg>)*)?
Expand All @@ -15,14 +15,15 @@
<for> ::= "for " "(" <expr> ")" (<fn> | <block>)
<while> ::= "while " "(" <expr> ")" (<fn> | <block>)
<match> ::= "match " "(" <expr> ")" "{ " <arm>+ "}"
<arm> ::= <expr> "=> " (<fn> | <block>)
<arm> ::= <expr> "=> " (<fn> | <block> | <or>)
<tag> ::= "tag " ("| " <ident> (":" <signature>)?)+
<enum> ::= "enum" "(" <val_type> ")" ("| " <ident> ("=" <expr>)?)+
<declarators> ::= (<declarator>)*
<declarator> ::= "pub "? <ident> (":" <signature>)?
<destructure> ::= ("{ " <ident> ("," <ident>)* " }") | <ident>
<args> ::= (<arg> ("," <arg>)*)?
<arg> ::= ("self " (": " <signature>)?) | <ident> (":" <signature>)?
<inner_decl> ::= ( "const " | "let ") <ident> (":" <signature>)? "= " <expr>
<inner_decl> ::= ( "const " | "let ") <destructure> (":" <signature>)? "= " <expr>
<reassign> ::= <access> ("= " <expr>)?
<block> ::= "{ " (<inner_decl> | <for> | <while> | <if> | <reassign>)* (<return> | <break>)? "}"
<return> ::= "return " <expr>?
Expand Down
8 changes: 5 additions & 3 deletions ir/Cargo.toml → fir/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
[package]
name = "ir"
name = "fir"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
ast = { path="../ast" }
oir = { path="../oir" }
symtable = { path="../symtable" }
datatable = { path="../datatable" }
typetable = { path="../typetable" }
scopetable = { path="../scopetable" }
token = { path="../token" }
perror = { path="../perror" }
lexer = { path="../lexer" }
linter = { path="../linter" }
types = { path="../types" }
cranelift-frontend = "0"
cranelift-codegen = "0"
cranelift-module = "0"
Loading

0 comments on commit 9501115

Please sign in to comment.