Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
23865af
fix: Fix typos in checked arithmetic
chadsec1 May 24, 2026
5ba4c7b
refactor: General code clean-up
chadsec1 May 24, 2026
cfb0162
fix: Fix typo in transpiler less than binary operation expression
chadsec1 May 24, 2026
630e243
feat: Lock variables expliclitly initialized, and unlock variables im…
chadsec1 May 25, 2026
c15cb5f
tests: Fix tests for new locked by default behavior
chadsec1 May 25, 2026
7f69aff
tests: Add unit tests for the transpiler
chadsec1 May 25, 2026
0f9a326
tests: Add unit tests for the transpiler
chadsec1 May 25, 2026
8ebc220
tests: Add unit-tests for the transpiler layer
chadsec1 May 26, 2026
2c47fa3
tests: Add unit-tests for the transpiler layer
chadsec1 May 26, 2026
59acba0
refactor: Set paniciking to abort, and disable optimizations
chadsec1 May 28, 2026
5b7f2bc
fix: Fix checked arthiemtic in transpiler
chadsec1 May 28, 2026
8e90558
fix: Fix checked arthiemtic in transpiler
chadsec1 May 28, 2026
f22f737
refactor: General code clean-up
chadsec1 May 28, 2026
fbdb087
tests: Use reflective blackbox testing approach instead of plain test…
chadsec1 May 28, 2026
cc9cf12
fix: Ensure main function cannot have return types nor parameters
chadsec1 May 28, 2026
6ece478
tests: Ensure main function cannot have return types nor parameters
chadsec1 May 28, 2026
48b82b4
tests: Add new transpiler unit tests
chadsec1 May 28, 2026
ecf8224
tests: Add new transpiler unit tests
chadsec1 May 28, 2026
27bee85
tests: Add new unit tests for break statements in the transpiler layer
chadsec1 May 29, 2026
869d0e4
tests: Add new unit tests for break statements in the transpiler layer
chadsec1 May 29, 2026
61b1f42
fix: Fix nested array literals and array access misparsing bugs
chadsec1 May 31, 2026
3ba37d6
fix: Fix nested array literals and array access misparsing bugs
chadsec1 May 31, 2026
2ea672e
docs: Update README example code
chadsec1 May 31, 2026
179a884
tests: Fix string escape tests
chadsec1 May 31, 2026
4067abf
tests: Add array literals contents helper function unit tests
chadsec1 May 31, 2026
5b0dd5a
refactor: General code clean-up
chadsec1 May 31, 2026
a85d8cc
fix: Fix parenthesis in strings causing crash
chadsec1 May 31, 2026
ef5240f
tests: Add parenthesis in strings in literals edge cases for parser u…
chadsec1 May 31, 2026
ec9f600
tests: Add parser helpers test for parenthesis get content f unction
chadsec1 May 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func main() {
#
own a int32 = 1
own b int32 = x
own b int32 = a
# This is invalid, it would not compile if I uncomment it.
# a = 2
Expand Down
1 change: 1 addition & 0 deletions src/ast/stmts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub struct VariableDeclaration {
pub name: String,
pub type_name: Type,
pub value: Expr,
pub explicitly_initialized: bool,
pub span: Span,
}

Expand Down
8 changes: 8 additions & 0 deletions src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ pub fn compile(rcode: &str, target_dir: &str) -> Result<(), HolyError> {
name = "holyprogram"
version = "0.0.1"
edition = "2024"

[profile.dev]
opt-level = 0
panic = "abort"

[profile.release]
opt-level = 0
panic = "abort"
"#;

cargo_file.write_all(cargo_content.as_bytes()).expect(&format!("Compile error: Couldnt write to file `{}`, please check your permissions", cargo_file_path.display()));
Expand Down
4 changes: 3 additions & 1 deletion src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ pub const RESERVED_KEYWORDS: &[&str] = &[
"func", "own", "const", "infinite", "return", "for", "in", "range", "if", "elif", "else", "true", "false",
"int8", "int16", "int32", "int64", "int128", "byte", "uint16", "uint32", "uint64",
"uint128", "float64", "usize", "bool", "string", "copy", "format",
"lock", "unlock", "while", "break", "continue", "and", "or", "not"
"lock", "unlock", "while", "break", "continue", "and", "or", "not",

"_checkedopsf64"
];
4 changes: 2 additions & 2 deletions src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ fn parse_stmt_line(line: &str, line_no: usize) -> Result<Stmt, HolyError> {

let value = parse_expr::parse_expr(right, span)?;

return Ok(Stmt::VarDecl(VariableDeclaration { name, type_name: var_type, value: value, span: span }));
return Ok(Stmt::VarDecl(VariableDeclaration { name, type_name: var_type, value: value, explicitly_initialized: true, span: span }));



Expand All @@ -722,7 +722,7 @@ fn parse_stmt_line(line: &str, line_no: usize) -> Result<Stmt, HolyError> {
let ty = parse_type(parts[1], &span)?;
let default_value = ty.get_default_value(span);

return Ok(Stmt::VarDecl(VariableDeclaration { name, type_name: ty, value: default_value, span: span }))
return Ok(Stmt::VarDecl(VariableDeclaration { name, type_name: ty, value: default_value, explicitly_initialized: false, span: span }))
}
}

Expand Down
12 changes: 10 additions & 2 deletions src/parser/blackbox_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn span() -> Span {
// all literals (ints, floats, array, strings literals of ints, floats, strings, other arrays, and variable names, and array access and slicing.
// Some of these literals are illegal semantically, but syntaxally, should be valid.
//
fn get_all_literals_edge_cases() -> [String; 126] {
fn get_all_literals_edge_cases() -> [String; 143] {
return [
i8::MIN.to_string(), i8::MAX.to_string(),
i16::MIN.to_string(), i16::MAX.to_string(),
Expand All @@ -109,7 +109,15 @@ fn get_all_literals_edge_cases() -> [String; 126] {

"false".to_string(), "true".to_string(),
"\"\"".to_string(), "\"h\"".to_string(), "\"hi\"".to_string(),
"\"hi, lmao\"".to_string(),
"\"hi, lmao\"".to_string(), "\"hi ] lmao\"".to_string(), "\"hi [ lmao\"".to_string(),
"\"foo]\"".to_string(), "\"foo[\"".to_string(),
"\"]foo\"".to_string(), "\"[foo\"".to_string(),
"\"]foo]\"".to_string(), "\"[foo[\"".to_string(),
"\"[foo]\"".to_string(),
"\"foo\\\"]\"".to_string(), "\"foo\\\"[\"".to_string(),
"\"\\\"]foo\"".to_string(), "\"\\\"[foo[\"".to_string(),
"\"foo)\"".to_string(), "\"foo(\"".to_string(),
"\")foo\"".to_string(), "\"(foo\"".to_string(),
"i".to_string(), "arr".to_string(), "x".to_string(), "y".to_string(), "xyz".to_string(),

format!("arr[{}]", i8::MIN.to_string()), format!("arr[{}]", i8::MAX.to_string()),
Expand Down
8 changes: 7 additions & 1 deletion src/parser/blackbox_tests/function_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,13 @@ mod function_tests {

assert!(result.is_err());
let assert_cond = result.unwrap_err().to_string();
assert!(assert_cond.contains("Unknown type") || assert_cond.contains("Missing opening parentheses for return type"));
println!("wtf? {:?}", assert_cond);

let assert_cond = assert_cond.contains("Unknown type") ||
assert_cond.contains("Missing opening parentheses for return type")
|| assert_cond.contains("Invalid parameter");

assert!(assert_cond);
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/parser/blackbox_tests/string_literal_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,16 @@ mod string_literals_tests {
#[test]
fn string_literal_with_escaped_quote() {
for t in ALL_TYPES_NO_ARR {
let stmts = parse_body(&format!("own x {} = \"say \\\"hi\\\"\"", t));
let stmts = parse_body(&format!(r#"own x {} = "say \"hi\"""#, t));
assert_eq!(stmts.len(), 1);

if let Stmt::VarDecl(v) = &stmts[0] {
assert_eq!(v.name, "x");
assert_eq!(v.type_name, t.clone());

println!("huh {:?}", v.value);
if let Expr::StringLiteral { value, .. } = &v.value {
assert_eq!(value, r#"say "hi""#);
assert_eq!(value, r#"say \"hi\""#);
} else { panic!(); }
} else { panic!("Expected VarDecl"); }
}
Expand Down
Loading
Loading