Skip to content

Commit

Permalink
Merge pull request #80 from behemehal/ParserFixes
Browse files Browse the repository at this point in the history
Parser fixes
  • Loading branch information
ahmtcn123 committed Nov 3, 2023
2 parents 7bb506e + 1f39f23 commit 41119f2
Show file tree
Hide file tree
Showing 58 changed files with 1,114 additions and 679 deletions.
36 changes: 34 additions & 2 deletions CHANGELOG.md
Expand Up @@ -39,7 +39,6 @@
- Tokenizer v0.3.3
- Fix comment bug [2723381f7f0f32e549c56a4e29a14ac3667c44a0](https://github.com/behemehal/Ellie-Language/commit/2723381f7f0f32e549c56a4e29a14ac3667c44a0)


# v0.7.0

- Parser v0.5.0
Expand Down Expand Up @@ -80,9 +79,42 @@
Fix code order problems [e4af101b8f51d297b23550826559a9c9ceebd516](https://github.com/behemehal/Ellie-Language/commit/e4af101b8f51d297b23550826559a9c9ceebd516)

# v0.8.2

- EllieEngine
Add tools && local registers [fb7a2797afa9d6b88b781d3120f0b7b0df9fdadb](https://github.com/behemehal/Ellie-Language/commit/fb7a2797afa9d6b88b781d3120f0b7b0df9fdadb)
- Tokenizer v0.4.6
Fix operator errors [38415a241962103f05ee47090b0a3946ee65bcac](https://github.com/behemehal/Ellie-Language/commit/38415a241962103f05ee47090b0a3946ee65bcac)

# v0.9.0
# v1.4.13-alpha

- ## ellie_tokenizer v0.5.2

- Add generic usage safety [201c53d0602f4ddcb4348dca1553689f135645a1](https://github.com/behemehal/Ellie-Language/commit/201c53d0602f4ddcb4348dca1553689f135645a1)

- ## ellie_parser v0.7.2

- Fix generics construction on class [5830b180388f5b4ed776c2281bbba0ef3ba17351](https://github.com/behemehal/Ellie-Language/commit/5830b180388f5b4ed776c2281bbba0ef3ba17351)
- Fix function parameter errors due to self calculation [c38269891fa2a6b9295167e820a26d68041c8893](https://github.com/behemehal/Ellie-Language/commit/c38269891fa2a6b9295167e820a26d68041c8893)
- Fix unnecessary calls [4d5a2389b6779a19f2c606fe8b0baa2b6e235c9d](https://github.com/behemehal/Ellie-Language/commit/4d5a2389b6779a19f2c606fe8b0baa2b6e235c9d)
- Fix loop's dependency errors [9d1f7a34c114055fdedc89d10c166604ace6c6a0](https://github.com/behemehal/Ellie-Language/commit/9d1f7a34c114055fdedc89d10c166604ace6c6a0)
- Add generic usage safety [201c53d0602f4ddcb4348dca1553689f135645a1](https://github.com/behemehal/Ellie-Language/commit/201c53d0602f4ddcb4348dca1553689f135645a1)

- ## ellie_fmt v0.5.2

- Implement cloak formatter & fix ret errors [6266f5d7464c1c9d82c78890a6c7901e837268ec](https://github.com/behemehal/Ellie-Language/commit/6266f5d7464c1c9d82c78890a6c7901e837268ec)

- ## ellie_vm v0.5.2

- Fix unnecessary calls & Add clean vm error show [4d5a2389b6779a19f2c606fe8b0baa2b6e235c9d](https://github.com/behemehal/Ellie-Language/commit/4d5a2389b6779a19f2c606fe8b0baa2b6e235c9d)
- Fix static array frame errors [746ee75c7fd74982e4054b158a478704c1a97b96](https://github.com/behemehal/Ellie-Language/commit/746ee75c7fd74982e4054b158a478704c1a97b96)
- Add more info to internal functions [2006dde05bc935b77ba83994317ac865ce8426c7](https://github.com/behemehal/Ellie-Language/commit/2006dde05bc935b77ba83994317ac865ce8426c7)

- ## ellie_bytecode v0.4.2

- Fix loop's dependency errors [9d1f7a34c114055fdedc89d10c166604ace6c6a0](https://github.com/behemehal/Ellie-Language/commit/9d1f7a34c114055fdedc89d10c166604ace6c6a0)

- ## elliec v0.3.1

- Add multiple output to elliec [68e3fb967af1f82b017af492da70f352b558a262](https://github.com/behemehal/Ellie-Language/commit/68e3fb967af1f82b017af492da70f352b558a262)

- Add more info to internal functions [2006dde05bc935b77ba83994317ac865ce8426c7](https://github.com/behemehal/Ellie-Language/commit/2006dde05bc935b77ba83994317ac865ce8426c7)
12 changes: 6 additions & 6 deletions ellie_engine/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "ellie_engine"
description = "Why ellie? Ellie is a type-safe programing language that runs on embedded and sandboxed environments."
version = "1.4.6-alpha"
version = "1.4.13-alpha"
authors = ["Ahmetcan Aksu <ahmetcanaksu@behemehal.org>", "Behemehal <info@behemehal.org>"]
edition = "2021"
license-file = "../LICENSE"
Expand All @@ -15,13 +15,13 @@ homepage = "https://www.ellie-lang.org"
serde = { version = "1.0", features = ["derive"], optional = true }
serde_json = { version = "1.0", default-features = false, features = ["alloc"], optional = true }
path-absolutize = { version = "3.0.10", optional = true }
ellie_core = { path = "core", version = "0.7.0" }
ellie_core = { path = "core", version = "0.7.1" }
#ellie_assist = { path = "EllieAssist", version = "*", optional = true }
ellie_tokenizer = { path = "tokenizer", version = "0.6.0", default-features = false, optional = true }
ellie_parser = { path = "parser", version = "0.7.0", default-features = false, optional = true }
ellie_bytecode = { path = "bytecode", version = "0.4.0", optional = true }
ellie_vm = { path = "vm", version = "0.5.0", optional = true }
ellie_fmt = { path = "fmt", version = "0.5.0", optional = true }
ellie_parser = { path = "parser", version = "0.7.2", default-features = false, optional = true }
ellie_bytecode = { path = "bytecode", version = "0.4.2", optional = true }
ellie_vm = { path = "vm", version = "0.5.2", optional = true }
ellie_fmt = { path = "fmt", version = "0.5.2", optional = true }
ellie_renderer_utils = { path = "renderer_utils", version = "0.3.0", optional = true, default-features = false }

[features]
Expand Down
6 changes: 3 additions & 3 deletions ellie_engine/bytecode/Cargo.toml
@@ -1,16 +1,16 @@
[package]
name = "ellie_bytecode"
description = "Bytecode assembler/encoder/decoder for ellie language"
version = "0.4.0"
version = "0.4.2"
edition = "2021"
authors = ["Ahmetcan Aksu <ahmetcanaksu@behemehal.org>", "Behemehal <info@behemehal.org>"]
license = "GPL-2.0"
repository = "https://github.com/behemehal/Ellie-Language"
homepage = "https://www.ellie-lang.org"

[dependencies]
ellie_core = { path = "../core", version = "0.7.0" }
ellie_parser = { path = "../parser", version = "0.7.0" }
ellie_core = { path = "../core", version = "0.7.1" }
ellie_parser = { path = "../parser", version = "0.7.2" }
enum-as-inner = "0.6.0"
lazy_static = "1.4.0"

Expand Down
3 changes: 2 additions & 1 deletion ellie_engine/bytecode/src/transpiler/loop_type.rs
Expand Up @@ -23,7 +23,8 @@ impl super::Transpiler for loop_type::Loop {
assembler.assemble_dependency(&dependency.hash);
}

let dependencies = vec![processed_page.hash];
let mut dependencies = vec![processed_page.hash];
dependencies.extend(processed_page.dependencies.iter().map(|d| d.hash));

//We need to get back at this point every time we jump to the end of the loop.
let start_pos = assembler.location() + 1;
Expand Down
11 changes: 1 addition & 10 deletions ellie_engine/bytecode/src/transpiler/type_resolver.rs
Expand Up @@ -851,19 +851,14 @@ pub fn resolve_type(
Some(vec![last_chain.page_hash]),
true,
);

std::println!("Range:\n{:#?}", assembler.instructions[_pos..].to_vec());
std::println!("found:\n{:#?}", found);
std::println!("found:\n{:#?}", last_pos);
is_reference = Some(last_pos);
found.unwrap()
}
_ => unreachable!("Unexpected target type"),
};

let previous_params_location = assembler.location() + 1;
if let Some(reference) = &is_reference {
std::println!("STB TO LOCATION: {}", reference);
if is_reference.is_some() {
assembler
.instructions
.push(instruction_table::Instructions::STB(Instruction::implicit()));
Expand All @@ -890,7 +885,6 @@ pub fn resolve_type(

if !function_call.params.is_empty() {
for (idx, param) in function_call.params.iter().enumerate() {
std::println!("INDEX: {}, PARAM: {:#?}", idx, param);
let idx = if is_reference.is_some() { idx + 1 } else { idx };
resolve_type(
assembler,
Expand All @@ -899,14 +893,12 @@ pub fn resolve_type(
target_page,
dependencies.clone(),
);
std::println!("STA TO LOCATION: {}", previous_params_location + idx);
assembler
.instructions
.push(instruction_table::Instructions::STA(Instruction::absolute(
previous_params_location + idx,
)));
}
std::println!("STA END")
}

assembler
Expand Down Expand Up @@ -1443,7 +1435,6 @@ pub fn resolve_type(
Some(e) => e,
None => panic!("Function Parameter not found: {}", e.name),
};
std::println!("pos: {:#?} {:#?}", pos, e);
let mut instructions = Vec::new();

match target_register {
Expand Down
4 changes: 2 additions & 2 deletions ellie_engine/bytecode/src/types.rs
Expand Up @@ -48,13 +48,13 @@ impl Types {
Types::String(str_len) => (6, *str_len),
Types::Char => (7, 4),
Types::Void => (8, 0),
Types::Array(array_len) => (9, *array_len),
Types::Array(_) => (9, platform_size.usize_len() as usize),
Types::Null => (10, 0),
Types::Class(_) => (11, platform_size.usize_len() as usize),
Types::Function => (12, platform_size.usize_len() as usize),
Types::HeapReference => (13, platform_size.usize_len() as usize),
Types::StackReference => (14, platform_size.usize_len() as usize),
Types::StaticArray => (15, 8),
Types::StaticArray => (15, platform_size.usize_len() as usize),
}
}

Expand Down
2 changes: 1 addition & 1 deletion ellie_engine/core/Cargo.toml
@@ -1,7 +1,7 @@
[package]
name = "ellie_core"
description = "Core modules for ellie"
version = "0.7.0"
version = "0.7.1"
authors = ["Ahmetcan Aksu <ahmetcanaksu@behemehal.org>", "Behemehal <info@behemehal.org>"]
edition = "2021"
license = "GPL-2.0"
Expand Down
63 changes: 63 additions & 0 deletions ellie_engine/core/src/definite/definers.rs
Expand Up @@ -222,4 +222,67 @@ impl DefinerCollecting {
DefinerCollecting::Dynamic => unreachable!(),
}
}

pub fn convert_generic(&mut self, generic_hash: usize, replacement_generic: DefinerCollecting) {
match self {
DefinerCollecting::Array(array) => {
array
.rtype
.convert_generic(generic_hash, replacement_generic);
}
DefinerCollecting::Generic(generic) => {
if generic.hash == generic_hash {
*self = replacement_generic;
}
}
DefinerCollecting::ParentGeneric(parrent_generic) => {
if parrent_generic.hash == generic_hash {
*self = replacement_generic;
} else {
parrent_generic.generics.iter_mut().for_each(|g| {
g.value
.convert_generic(generic_hash, replacement_generic.clone())
});
}
}
DefinerCollecting::Function(function) => {
function
.params
.iter_mut()
.for_each(|param: &mut DefinerCollecting| {
param.convert_generic(generic_hash, replacement_generic.clone())
});
function
.returning
.convert_generic(generic_hash, replacement_generic.clone());
}
DefinerCollecting::Cloak(cloak) => {
cloak
.rtype
.iter_mut()
.for_each(|r| r.convert_generic(generic_hash, replacement_generic.clone()));
}
DefinerCollecting::Collective(collective) => {
collective
.key
.convert_generic(generic_hash, replacement_generic.clone());
collective
.value
.convert_generic(generic_hash, replacement_generic);
}
DefinerCollecting::Nullable(nullable) => {
nullable
.value
.convert_generic(generic_hash, replacement_generic);
}
DefinerCollecting::EnumField(enum_field) => match &mut enum_field.field_data {
EnumFieldData::NoData => (),
EnumFieldData::Data(enum_field_data) => {
enum_field_data.convert_generic(generic_hash, replacement_generic)
}
},
DefinerCollecting::Dynamic => (),
DefinerCollecting::ClassInstance(_) => (),
}
}
}

0 comments on commit 41119f2

Please sign in to comment.