Skip to content

Commit

Permalink
Merge pull request #22 from JCBurnside/feature/arrays-and-tuples
Browse files Browse the repository at this point in the history
Feature/arrays and tuples
  • Loading branch information
JCBurnside authored Mar 19, 2024
2 parents ba30eff + 7e93e01 commit 2457b1a
Show file tree
Hide file tree
Showing 20 changed files with 3,199 additions and 1,639 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{"name": "RUST_BACKTRACE", "value": "1"}
],
"console": "externalTerminal",
"preLaunchTask": "rust: cargo build"
"preLaunchTask": "build"
},
{
"name": "test",
Expand All @@ -37,7 +37,7 @@
"cwd": "${workspaceFolder}",
"env": {"RUST_BACKTRACE": "1"},
"console": "externalTerminal",
"preLaunchTask": "rust: cargo build"
"preLaunchTask": "build"
}
]
}
12 changes: 3 additions & 9 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,12 @@
"version": "2.0.0",
"tasks": [
{
"label": "MyTask",
"label": "build",
"type": "shell",
"command": "cargo build"
},
{
"type": "cargo",
"command": "build",
"command": "cargo build",
"problemMatcher": [
"$rustc"
],
"group": "build",
"label": "rust: cargo build"
}
},
]
}
26 changes: 17 additions & 9 deletions cli/test.fb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*
let test_ifs a b : bool -> bool -> int32 =
if a then
print_str "a\n";
Expand All @@ -20,7 +21,9 @@ let test_ifexpr a b : bool -> bool -> int32 = if a then
4

extern "C" let externed : int32 -> int32;

*/
let f (a:[int32;5]) = ();
/*
let show_short_curicuit _ : () -> () =
if (show_something ()) && (show_something_else ()) then
print_str "this is a seperator\n";
Expand All @@ -38,13 +41,18 @@ let show_something_else _ : () -> bool =
print_str "general kenobi\n";
return false;

let main _ : () -> () =
let a : bool = true;
let test (a:(int32,int32)) =
let x : int32 = 0;
match x where
| 1 -> print_str "one",
| 2 -> print_str "two",
print_str "main";
show_short_curicuit ();
let y = externed 0;
return x;
*/
let main _ : () -> () =
// let a : bool = true;
// let x : int32 = 0;
// match x where
// | 1 -> print_str "one",
// | 2 -> print_str "two",
// print_str "main";
// show_short_curicuit ();
// let y = externed 0;
f [1,2,3,4,5];
return ();
17 changes: 7 additions & 10 deletions compiler/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ impl Declaration {

#[derive(Debug, PartialEq, Clone)]
pub struct GenericsDecl {
pub for_loc : crate::Location,
pub decls : Vec<(crate::Location,String)>
pub for_loc: crate::Location,
pub decls: Vec<(crate::Location, String)>,
}

#[derive(Debug, PartialEq, Clone)]
Expand Down Expand Up @@ -186,13 +186,13 @@ pub struct FieldDecl {
pub struct ArgDeclaration {
pub loc: crate::Location,
pub ident: String,
pub ty: Option<ResolvedType>,
pub ty: Option<ResolvedType>,
}

#[derive(PartialEq,Debug, Clone)]
#[derive(PartialEq, Debug, Clone)]
pub struct Abi {
pub loc : crate::Location,
pub identifier : String,
pub loc: crate::Location,
pub identifier: String,
}

#[derive(PartialEq, Debug)]
Expand All @@ -204,7 +204,7 @@ pub struct ValueDeclaration {
pub ty: Option<ResolvedType>,
pub value: ValueType,
pub generictypes: Option<GenericsDecl>,
pub abi : Option<Abi>,
pub abi: Option<Abi>,
}
impl ValueDeclaration {
fn replace(&mut self, nice_name: &str, actual: &str) {
Expand Down Expand Up @@ -502,9 +502,6 @@ pub enum Expr {
/// basically an ident on it's own
ValueRead(String, crate::Location),

/// NOT IMPLEMENTED YET
/// defined like [ expr, expr, expr, ... ]
/// type [T;N]
ArrayLiteral {
contents: Vec<Expr>,
loc: crate::Location,
Expand Down
Loading

0 comments on commit 2457b1a

Please sign in to comment.