Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Fuel HLL #2

Merged
merged 71 commits into from May 8, 2021
Merged
Show file tree
Hide file tree
Changes from 56 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
159e747
initial parsing work
Jan 25, 2021
32d3ae5
parse trait declarations
Jan 27, 2021
42a8e80
import statements
Jan 27, 2021
c85792c
clean lexer tree; support method calls
Jan 27, 2021
9e71dda
basic ast skeleton beginnings
Jan 28, 2021
7a4edec
begin ast work
Jan 29, 2021
f767f96
checkpoint while i swap computers
Jan 29, 2021
40eb817
more ast parsing
Jan 29, 2021
8b7f12a
more ast parsing
Jan 29, 2021
e7bdaeb
ast: function appl, func decl, var exp
Jan 31, 2021
80ae5a9
ast: literals
Jan 31, 2021
73c4438
add compiler binary with nice error messages
Feb 1, 2021
d58e28b
ast: return statements, use statements
Feb 1, 2021
d40b2f2
fix error message
Feb 1, 2021
2e347c2
ast: traits
Feb 1, 2021
2a9edf9
more friendly parse error messages
Feb 1, 2021
d02fc85
old email
Feb 1, 2021
afdeef7
semicolons!
Feb 2, 2021
29ae513
byte literals; fix tests
Feb 3, 2021
5f8a909
parse binary and hex literals for byte and bytes32
Feb 4, 2021
9da8276
refactor expression parsing
Feb 4, 2021
8073cea
parse array exprs
Feb 4, 2021
6ddcb49
parse operator expressions
Feb 4, 2021
88e9fa5
type ascriptions
Feb 9, 2021
303f826
parser: polymorphism and trait bounds
Feb 9, 2021
f084b97
default to u64 instead of u32
Feb 10, 2021
720abfa
begin work on match statements
Feb 11, 2021
d23420c
parse structs
Feb 12, 2021
66b641c
refactor
Feb 13, 2021
3f2e581
a few program examples; parse match statements
Feb 13, 2021
f9234a6
lex struct expressions
Feb 16, 2021
4b2b948
parse to AST struct expressions
Feb 16, 2021
9e69615
compile warnings!
Feb 16, 2021
13e6a30
assert_or_warn macro
Feb 16, 2021
2af1365
generic struct parameters
Feb 17, 2021
98b46fa
parse contract/script/predicate
Feb 18, 2021
a11bf95
improve top level failure error message
Feb 18, 2021
937267e
s/ast/parse_tree
Feb 20, 2021
2f389a3
enums
Feb 20, 2021
0747988
begin semantic analysis
Feb 20, 2021
fc38750
begin work on type checking, inferencing, and semantics checking (#11)
sezna Feb 26, 2021
3b028e6
small error msg tweak
Feb 26, 2021
f7261d0
Refactor error and warning handling (#12)
sezna Mar 2, 2021
952ff98
type check predicates
Mar 3, 2021
029ea46
limit number of script main functions
Mar 3, 2021
217aa36
parse generic types for traits
Mar 4, 2021
3bed768
grammar for reassignments and while loops
Mar 4, 2021
ffa2450
variable reassignments; while loops
Mar 4, 2021
3eacf66
check generic type params in function declarations
Mar 4, 2021
6956d71
fix tests
Mar 5, 2021
d31ead1
grammar for inline asm
Mar 5, 2021
d74420a
Asm expressions (#13)
sezna Mar 28, 2021
ae30683
fix only last expr having type annotation; if branch enforcement of h…
Mar 30, 2021
a20104f
Control flow analysis + more (#28)
sezna Apr 16, 2021
12a0efa
add line_col method for errors and warnings
May 3, 2021
c7c73a9
Generate Assembly (#31)
sezna May 6, 2021
0a8a601
move license; clean warnings
May 6, 2021
e494d0c
Update forc/src/cli/build.rs
sezna May 6, 2021
09f3107
Update forc/src/cli/build.rs
sezna May 6, 2021
2d47def
code review feedback
May 6, 2021
f9a5a57
Merge branch 'parser_v1' of github.com:fuellabs/fuel-vm-hll into pars…
May 6, 2021
61c5b6e
Update forc/src/manifest.rs
sezna May 6, 2021
6b7b5b3
Update parser/src/control_flow_analysis/analyze_return_paths.rs
sezna May 6, 2021
824f0fd
more PR feedback
May 6, 2021
0e2793b
Merge branch 'parser_v1' of github.com:fuellabs/fuel-vm-hll into pars…
May 6, 2021
9328fcd
rename parser to core_lang
May 6, 2021
0127a8d
add minimum supported version
May 7, 2021
ee149cd
Update README.md
sezna May 7, 2021
a7416ce
check that struct size in words fits in a u32 gracefully
May 7, 2021
cfdfbcb
Merge branch 'parser_v1' of github.com:fuellabs/fuel-vm-hll into pars…
May 8, 2021
f1e8ff5
forgotten import
May 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
**/*/target/
target

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
10 changes: 2 additions & 8 deletions Cargo.toml
@@ -1,9 +1,3 @@
[package]
name = "hll"
version = "0.1.0"
authors = ["Alex <alex.hansen@fuel.sh>"]
edition = "2018"
[workspace]

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

[dependencies]
members = ["parser", "forc"]
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

8 changes: 8 additions & 0 deletions example_project/fuel_project/Forc.toml
@@ -0,0 +1,8 @@
[project]
author = "Alex Hansen"
license = "MIT"
name = "Fuel example project"


[dependencies]
std = { path = "../../stdlib" }
82 changes: 82 additions & 0 deletions example_project/fuel_project/src/main.fm
@@ -0,0 +1,82 @@
script{
// Count to 5 and return the number 5.
sezna marked this conversation as resolved.
Show resolved Hide resolved
/*
fn foo() -> u32 {
let mut x = 0;
let mut y = 1;
while x < 5 {
x = x + 1;
y = y + 1;
x = x - 1;
x = x + 1;
}

5u32
}
*/

enum MyEnum {
Variant1: u32,
Variant2: ()
}

fn test() {
let x: MyEnum = MyEnum::Variant1(6 + 2);
let y = MyEnum::Variant2;
return;
}


trait MyTrait {
fn to_implement(a: self) -> Self;
}

impl MyTrait for MyEnum {
fn to_implement(a: MyEnum) -> Self {
a
}
}

struct MyStruct {
field_1: u32,
field_2: u32
}

pub fn main() -> bool {
let a = 5;
let z: byte = 0b01010101;
let x: byte32 = 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff;
let mut b = 5 + a;
while b < 100 {
b = b + 1;
}
let a = MyStruct {
field_1: 5u32,
field_2: 2u32,
};

//let a = a.field_1 + 2;
while false { let z = 0; }

/*
let z = MyEnum::Variant2;
let z = MyEnum::Variant1(10u32);
if true {
let z = z.to_implement();
return true;
} else {
let a = 5;
};
*/

true
}

/*
fn bar() {
let x = 5;
let y = x;
let z = y;
}
*/
}
61 changes: 61 additions & 0 deletions example_project/fuel_project/src/old_main.fm
@@ -0,0 +1,61 @@
script {
struct Fuel {
john: u64,
nick: u64,
}

impl Fuel {
fn fuel_add(self, other: Self) -> Self {
Fuel {
john: self.john + other.john,
nick: self.nick + other.nick,
}
}
}

fn foo(a: u64) -> u64 {
let st = Fuel { john: a, nick: a, };
st.john
}

fn main() -> u64 {
let z = Fuel {
john: 10,
nick: 11u64,
};
let x = Fuel {
john: 10,
nick: 11u64,
};

// return if true { foo(5u64) };
return z.john;
// x.fuel_add(z); TODO fix this code block return type in control flow analysis
// to recreate that scenario, remove the implicit return
5u64
}




/*

if x < 5 {
return true;
}
else {
return 5;
};
fn main() {
let a = 6 + 2;
a.a_function(10);

}
impl ExampleTrait for u64 {
fn a_function(a: u64) -> u64 {
a
}
}
*/

}
18 changes: 18 additions & 0 deletions forc/Cargo.toml
@@ -0,0 +1,18 @@
[package]
name = "forc"
version = "0.1.0"
authors = ["Alex Hansen <alex.hansen@fuel.sh>"]
edition = "2018"

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

[dependencies]
parser = { path = "../parser" }
structopt = "0.3"
source-span = "2.2"
sezna marked this conversation as resolved.
Show resolved Hide resolved
termcolor = "1.1"
line-col = "0.2"
toml = "0.5"
serde = { version = "1.0", features = ["derive"] }
whoami = "1.1"
pest = "2.1"