diff --git a/.idea/shelf/Uncommitted_changes_before_Update_at_25_07_2024,_16_23_[Changes]/shelved.patch b/.idea/shelf/Uncommitted_changes_before_Update_at_25_07_2024,_16_23_[Changes]/shelved.patch
new file mode 100644
index 0000000..eade7fb
--- /dev/null
+++ b/.idea/shelf/Uncommitted_changes_before_Update_at_25_07_2024,_16_23_[Changes]/shelved.patch
@@ -0,0 +1,82 @@
+Index: .idea/workspace.xml
+IDEA additional info:
+Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
+<+>\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n \n \n \n {\n "lastFilter": {\n "state": "OPEN",\n "assignee": "Robert-M-Lucas"\n }\n}\n \n \n \n {\n "selectedUrlAndAccountId": {\n "url": "https://github.com/Robert-M-Lucas/whython-8.git",\n "accountId": "dcb8df19-0b39-47e1-9073-4a54f7034be8"\n }\n}\n \n \n \n \n \n \n {\n "customColor": "",\n "associatedIndex": 4\n}\n \n \n \n \n \n {\n "keyToString": {\n "Cargo.Run whython-8.executor": "Run",\n "Cargo.Test whython-8.executor": "Run",\n "RunOnceActivity.OpenProjectViewOnStart": "true",\n "RunOnceActivity.ShowReadmeOnStart": "true",\n "RunOnceActivity.rust.reset.selective.auto.import": "true",\n "Shell Script.Test Asm.executor": "Run",\n "git-widget-placeholder": "master",\n "ignore.virus.scanning.warn.message": "true",\n "last_opened_file_path": "/home/robertlucas/RustroverProjects/trace",\n "node.js.detected.package.eslint": "true",\n "node.js.detected.package.tslint": "true",\n "node.js.selected.package.eslint": "(autodetect)",\n "node.js.selected.package.tslint": "(autodetect)",\n "nodejs_package_manager_path": "npm",\n "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",\n "org.rust.cargo.project.model.impl.CargoExternalSystemProjectAware.subscribe.first.balloon": "",\n "org.rust.first.attach.projects": "true",\n "settings.editor.selected.configurable": "preferences.keymap",\n "vue.rearranger.settings.migration": "true"\n },\n "keyToStringList": {\n "com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [\n "Rust"\n ]\n }\n}\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n \n \n \n \n 1714088144106\n \n \n 1714088144106\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n 1714089790504\n \n \n \n 1714089790504\n \n \n \n 1717349672242\n \n \n \n 1717349672242\n \n \n \n 1717355914137\n \n \n \n 1717355914137\n \n \n \n 1717432257327\n \n \n \n 1717432257327\n \n \n \n 1717432916642\n \n \n \n 1717432916642\n \n \n \n 1717434442792\n \n \n \n 1717434442792\n \n \n \n 1717469659146\n \n \n \n 1717469659146\n \n \n \n 1717473113692\n \n \n \n 1717473113692\n \n \n \n 1717473365560\n \n \n \n 1717473365560\n \n \n \n 1717562697947\n \n \n \n 1717562697947\n \n \n \n 1717570846946\n \n \n \n 1717570846946\n \n \n \n 1717572031837\n \n \n \n 1717572031837\n \n \n \n 1717578308406\n \n \n \n 1717578308406\n \n \n \n 1717598684770\n \n \n \n 1717598684770\n \n \n \n 1717599815108\n \n \n \n 1717599815108\n \n \n \n 1717614243407\n \n \n \n 1717614243407\n \n \n \n 1717614696137\n \n \n \n 1717614696137\n \n \n \n 1717677552390\n \n \n \n 1717677552390\n \n \n \n 1717684897421\n \n \n \n 1717684897422\n \n \n \n 1717705529640\n \n \n \n 1717705529640\n \n \n \n 1717769943602\n \n \n \n 1717769943602\n \n \n \n 1717794101530\n \n \n \n 1717794101530\n \n \n \n 1717794233364\n \n \n \n 1717794233364\n \n \n \n 1717794747334\n \n \n \n 1717794747334\n \n \n \n 1717819316020\n \n \n \n 1717819316020\n \n \n \n 1717826853448\n \n \n \n 1717826853448\n \n \n \n 1718558711741\n \n \n \n 1718558711741\n \n \n \n 1718558898901\n \n \n \n 1718558898901\n \n \n \n 1718636633009\n \n \n \n 1718636633009\n \n \n \n 1718798005819\n \n \n \n 1718798005819\n \n \n \n 1718798188305\n \n \n \n 1718798188305\n \n \n \n 1718799244388\n \n \n \n 1718799244388\n \n \n \n 1718803787262\n \n \n \n 1718803787262\n \n \n \n 1718805301324\n \n \n \n 1718805301324\n \n \n \n 1718888868217\n \n \n \n 1718888868217\n \n \n \n 1718889832262\n \n \n \n 1718889832262\n \n \n \n 1718895358320\n \n \n \n 1718895358320\n \n \n \n 1718928037028\n \n \n \n 1718928037028\n \n \n \n 1718928163157\n \n \n \n 1718928163157\n \n \n \n 1718963722966\n \n \n \n 1718963722967\n \n \n \n 1718964303334\n \n \n \n 1718964303334\n \n \n \n 1718968546046\n \n \n \n 1718968546046\n \n \n \n 1719323220161\n \n \n \n 1719323220162\n \n \n \n 1719323378191\n \n \n \n 1719323378191\n \n \n \n 1719324580280\n \n \n \n 1719324580280\n \n \n \n 1719324945974\n \n \n \n 1719324945974\n \n \n \n 1719325143424\n \n \n \n 1719325143424\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
+Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
+<+>UTF-8
+===================================================================
+diff --git a/.idea/workspace.xml b/.idea/workspace.xml
+--- a/.idea/workspace.xml (revision 68a28d719d1170416b82f57ac205cdacf10ff409)
++++ b/.idea/workspace.xml (date 1721921020000)
+@@ -7,17 +7,7 @@
+
+
+
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
+-
++
+
+
+
+@@ -224,6 +214,7 @@
+
+
+
++
+
+
+
+@@ -601,7 +592,23 @@
+
+ 1719325143424
+
+-
++
++
++ 1721915067389
++
++
++
++ 1721915067389
++
++
++
++ 1721916444578
++
++
++
++ 1721916444578
++
++
+
+
+
+@@ -619,8 +626,6 @@
+
+
+
+-
+-
+
+
+
+@@ -644,7 +649,9 @@
+
+
+
+-
++
++
++
+
+
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0c1960d..1b712e7 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,16 +7,19 @@
-
+
+
+
+
+
+
+
+
-
-
+
-
-
-
@@ -226,7 +229,7 @@
-
+
@@ -604,7 +607,15 @@
1719325143424
-
+
+
+ 1721950132807
+
+
+
+ 1721950132807
+
+
@@ -622,7 +633,6 @@
-
@@ -647,7 +657,8 @@
-
+
+
diff --git a/build/out.asm b/build/out.asm
index d0dc577..5816433 100644
--- a/build/out.asm
+++ b/build/out.asm
@@ -5,10 +5,15 @@ section .text
main:
push rbp
mov rbp, rsp
- mov qword [rbp-8], 3
+ mov qword [rbp-8], 13
+ ; Test Start
+ mov qword [rbp-32], 3
+ mov qword [rbp-24], 5
+ mov qword [rbp-16], 4
+ ; Test End
mov rax, qword [rbp-8]
- mov qword [rbp-16], rax
- mov rax, qword [rbp-16]
+ mov qword [rbp-40], rax
+ mov rax, qword [rbp-40]
leave
ret
diff --git a/build/out.o b/build/out.o
index f141baa..a1996c6 100644
Binary files a/build/out.o and b/build/out.o differ
diff --git a/build/out.out b/build/out.out
index 25f56e7..067af02 100755
Binary files a/build/out.out and b/build/out.out differ
diff --git a/main.why b/main.why
index 6fd114f..4cb5186 100644
--- a/main.why
+++ b/main.why
@@ -1,16 +1,27 @@
struct StructA {
- a: StructB
+ a: int,
+ b: StructB
}
struct StructB {
- a: StructC
-}
-
-struct StructC {
- a: StructB
+ a: int,
+ b: int
}
fn main() -> int {
- let y: int = 3;
+ let y: int = 13;
+
+ @ Test Start
+
+ let x: StructA = StructA {
+ a: 3,
+ b: StructB {
+ a: 5,
+ b: 4
+ }
+ };
+
+ @ Test End
+
return y;
}
diff --git a/src/root/compiler/compile_function.rs b/src/root/compiler/compile_function.rs
index d2088d2..1b5b899 100644
--- a/src/root/compiler/compile_function.rs
+++ b/src/root/compiler/compile_function.rs
@@ -191,6 +191,9 @@ fn recursively_compile_lines(fid: FunctionID, lines: &[LineTokens], return_varia
LineTokens::NoOp(et) => {
contents.other(&compile_evaluable_reference(fid, et, local_variables, global_table, global_tracker)?.0);
}
+ LineTokens::Marker(value) => {
+ contents.line(&format!(";{}", value.value()));
+ }
}
}
diff --git a/src/root/parser/parse_arguments.rs b/src/root/parser/parse_arguments.rs
index 6d7168b..ad0f82e 100644
--- a/src/root/parser/parse_arguments.rs
+++ b/src/root/parser/parse_arguments.rs
@@ -1,6 +1,7 @@
use nom::bytes::complete::take_until;
use nom::InputTake;
use crate::root::parser::parse::{ErrorTree, ParseResult, Span};
+use crate::root::parser::parse_blocks::take_until_discard_smart;
use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, EvaluableTokens, parse_evaluable};
use crate::root::parser::parse_name::SimpleNameToken;
@@ -11,8 +12,8 @@ pub fn parse_arguments<'a, 'b>(s: Span<'a>, containing_class: Option<&'b SimpleN
loop {
// TODO: Account for brackets
- let (ns, section) = if let Ok((ns, section)) = take_until::<_, _, ErrorTree>(",")(s) {
- (ns.take_split(1).0, section)
+ let (ns, section) = if let Ok((ns, section)) = take_until_discard_smart(s, ",") {
+ (ns, section)
}
else {
last = true;
diff --git a/src/root/parser/parse_blocks.rs b/src/root/parser/parse_blocks.rs
index d66e661..aba3422 100644
--- a/src/root/parser/parse_blocks.rs
+++ b/src/root/parser/parse_blocks.rs
@@ -105,11 +105,13 @@ pub fn parse_terminator<'a, 'b, 'c>(s: Span<'a>, terminator: &'b Terminator, all
Err(nom::Err::Error(ErrorTree::from_char(s, terminator.closing)))
}
-pub fn take_until_or_end_smart<'a>(s: Span<'a>, until: &str) -> ParseResult<'a> {
+pub fn take_until_or_end_discard_smart<'a>(s: Span<'a>, until: &str) -> ParseResult<'a> {
let original = s.clone();
let mut s = s;
+ let mut found = false;
while !s.is_empty() {
if let Ok((ns, _)) = tag::<&str, LocatedSpan<&str, &Rc>, ErrorTree>(until)(s) {
+ found = true;
s = ns;
break;
}
@@ -127,11 +129,15 @@ pub fn take_until_or_end_smart<'a>(s: Span<'a>, until: &str) -> ParseResult<'a>
}
let offset = original.offset(&s);
+ let (end, mut inner) = original.take_split(offset);
+ if found {
+ inner = inner.take(inner.len() - until.len());
+ }
- Ok(original.take_split(offset))
+ Ok((end, inner))
}
-pub fn take_until_smart<'a>(s: Span<'a>, until: &str) -> ParseResult<'a> {
+pub fn take_until_discard_smart<'a>(s: Span<'a>, until: &str) -> ParseResult<'a> {
let original = s.clone();
let mut s = s;
loop {
@@ -157,6 +163,8 @@ pub fn take_until_smart<'a>(s: Span<'a>, until: &str) -> ParseResult<'a> {
}
let offset = original.offset(&s);
+ let (end, inner) = original.take_split(offset);
+ let inner = inner.take(inner.len() - until.len());
- Ok(original.take_split(offset))
+ Ok((end, inner))
}
diff --git a/src/root/parser/parse_function.rs b/src/root/parser/parse_function.rs
index 0cb1e6a..ae10eaa 100644
--- a/src/root/parser/parse_function.rs
+++ b/src/root/parser/parse_function.rs
@@ -23,6 +23,7 @@ pub mod parse_operator;
pub mod parse_return;
pub mod parse_while;
mod parse_struct_init;
+mod parse_marker;
#[derive(Debug, Getters, Dissolve)]
pub struct FunctionToken {
diff --git a/src/root/parser/parse_function/parse_line.rs b/src/root/parser/parse_function/parse_line.rs
index c1d1e41..0caac96 100644
--- a/src/root/parser/parse_function/parse_line.rs
+++ b/src/root/parser/parse_function/parse_line.rs
@@ -9,6 +9,8 @@ use crate::root::parser::parse_function::parse_return::{test_parse_return, Retur
use crate::root::parser::parse_function::parse_while::{test_parse_while, WhileToken};
use nom::branch::alt;
use nom::Parser;
+#[cfg(debug_assertions)]
+use crate::root::parser::parse_function::parse_marker::{MarkerToken, test_parse_marker};
use crate::root::parser::parse_name::SimpleNameToken;
use crate::root::parser::parse_util::discard_ignored;
@@ -20,6 +22,8 @@ pub enum LineTokens {
Return(ReturnToken),
Break(BreakToken),
NoOp(EvaluableToken),
+ #[cfg(debug_assertions)]
+ Marker(MarkerToken)
}
/// fn(line span, Option)
@@ -51,6 +55,8 @@ pub fn parse_line<'a, 'b>(s: Span<'a>, containing_class: Option<&'b SimpleNameTo
test_parse_initialisation,
test_parse_while,
test_parse_if,
+ #[cfg(debug_assertions)]
+ test_parse_marker
// test_parse_assignment,
))
.parse(s)
diff --git a/src/root/parser/parse_function/parse_marker.rs b/src/root/parser/parse_function/parse_marker.rs
new file mode 100644
index 0000000..dbdb01f
--- /dev/null
+++ b/src/root/parser/parse_function/parse_marker.rs
@@ -0,0 +1,40 @@
+use derive_getters::Getters;
+use nom::bytes::complete::take_till;
+use nom::character::complete::char;
+use nom::sequence::Tuple;
+use nom_supreme::tag::complete::tag;
+use crate::root::parser::parse::{ErrorTree, Location, ParseResult, Span};
+use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, parse_evaluable};
+use crate::root::parser::parse_function::parse_line::{LineTestFn, LineTokens};
+use crate::root::parser::parse_name::SimpleNameToken;
+use crate::root::parser::parse_util::{discard_ignored, require_ignored};
+
+#[derive(Debug, Getters)]
+pub struct MarkerToken {
+ value: String,
+}
+
+#[cfg(debug_assertions)]
+pub fn test_parse_marker<'a, 'b>(s: Span<'a>) -> ParseResult> {
+ match (char('@'), require_ignored).parse(s) {
+ Ok(_) => Ok((s, |x, _| {
+ parse_marker(x).map(|(s, x)| (s, LineTokens::Marker(x)))
+ })),
+ Err(e) => Err(e),
+ }
+}
+
+#[cfg(debug_assertions)]
+pub fn parse_marker(s: Span) -> ParseResult {
+ let (s, _) = char('@')(s)?;
+ let (s, value) = take_till(|c| c == '\n' || c == '\r')(s)?;
+
+ let (s, _) = discard_ignored(s)?;
+
+ Ok((
+ s,
+ MarkerToken {
+ value: value.fragment().to_string()
+ }
+ ))
+}
diff --git a/src/root/parser/parse_function/parse_struct_init.rs b/src/root/parser/parse_function/parse_struct_init.rs
index 56e712a..742486a 100644
--- a/src/root/parser/parse_function/parse_struct_init.rs
+++ b/src/root/parser/parse_function/parse_struct_init.rs
@@ -4,7 +4,7 @@ use nom::bytes::complete::{tag, take_till};
use nom::bytes::streaming::take_until;
use nom::character::streaming::char;
use crate::root::parser::parse::{Location, ParseResult, Span};
-use crate::root::parser::parse_blocks::{BRACE_TERMINATOR, parse_terminator_default_set};
+use crate::root::parser::parse_blocks::{BRACE_TERMINATOR, parse_terminator_default_set, take_until_or_end_discard_smart};
use crate::root::parser::parse_function::parse_evaluable::{EvaluableToken, EvaluableTokens, FullNameToken, FullNameWithIndirectionToken, parse_evaluable, parse_full_name};
use crate::root::parser::parse_function::parse_literal::{LiteralToken, LiteralTokens};
use crate::root::parser::parse_name::{parse_simple_name, SimpleNameToken};
@@ -40,8 +40,8 @@ pub fn parse_struct_init<'a, 'b>(s: Span<'a>, containing_class: Option<&'b Simpl
let (ns, _) = char(':')(ns)?;
let (ns, _) = discard_ignored(ns)?;
- let (ns, to_eval) = take_till(|c| c == ',')(ns)?;
- let ns = if ns.is_empty() { ns } else { char(',')(ns)?.0 };
+ let (ns, to_eval) = take_until_or_end_discard_smart(ns, ",")?;
+ println!("{:?} - {:?}", ns.fragment(), to_eval.fragment());
let (_, eval) = parse_evaluable(to_eval, containing_class, false)?;
contents.push((name, eval));
s = ns;