-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from kneorain/ast-parser-v5
Finally Completed - 90% of the Ast Parser **v5**
- Loading branch information
Showing
107 changed files
with
255,220 additions
and
3,347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "libs/llvm-18.1.9-src"] | ||
path = libs/llvm-18.1.9-src | ||
url = https://github.com/kneorain/llvm-project | ||
[submodule "libs/PEGTL"] | ||
path = libs/PEGTL | ||
url = https://github.com/taocpp/PEGTL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
@echo off | ||
setlocal | ||
|
||
rem Build the helix project using xmake | ||
xmake | ||
rem Initialize an empty variable to collect the remaining arguments | ||
set "ARGS=" | ||
|
||
rem Run the helix project with all arguments passed to the batch file | ||
build\debug\x64-msvc-windows\bin\helix %* | ||
rem Check if the first argument is '--' | ||
if "%1" == "--" ( | ||
rem Shift to remove the '--' | ||
shift | ||
) else ( | ||
rem Build the Helix project using xmake | ||
xmake | ||
) | ||
|
||
rem Collect all the remaining arguments after '--' | ||
:loop | ||
if "%1"=="" goto endloop | ||
set "ARGS=%ARGS% %1" | ||
shift | ||
goto loop | ||
|
||
:endloop | ||
rem Now run the binary with the collected arguments, without passing '--' | ||
build\debug\x64-msvc-windows\bin\helix %ARGS% | ||
|
||
endlocal |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
//===----------------------------------------- Helix ------------------------------------------===// | ||
// // | ||
// Part of the Helix Project, under the Attribution 4.0 International license (CC BY 4.0). // | ||
// You are allowed to use, modify, redistribute, and create derivative works, even for commercial // | ||
// purposes, provided that you give appropriate credit, and indicate if changes were made. // | ||
// For more information, please visit: https://creativecommons.org/licenses/by/4.0/ // | ||
// // | ||
// SPDX-License-Identifier: CC-BY-4.0 // | ||
// Copyright (c) 2024 (CC BY 4.0) // | ||
// // | ||
//===------------------------------------------------------------------------------------------===// | ||
|
||
#[link-time] | ||
import types::{Allocator}; | ||
import alloc::{DefaultAllocator}; | ||
|
||
class IntNode { | ||
let data: int; | ||
let link: *IntNode? = &null; | ||
|
||
fn IntNode(self, data: int, link: *IntNode?) { | ||
self.data = data; | ||
self.link = link; | ||
} | ||
|
||
fn getData(self) -> int { | ||
return self.data; | ||
} | ||
|
||
fn getLink(self) -> *IntNode? { | ||
return self.link; | ||
} | ||
|
||
fn setData(self, new_data: int) { | ||
self.data = new_data; | ||
} | ||
|
||
fn setLink(self, new_link: *IntNode?) { | ||
self.link = new_link; | ||
} | ||
|
||
fn addNodeAfter(self, new_data: int) -> *IntNode { | ||
let link = IntNode(new_data, self.link); | ||
self.link = &link; | ||
return &link; | ||
} | ||
} | ||
|
||
fn listLength(head: *IntNode) -> int { | ||
let count = 0; | ||
let *current = head; | ||
|
||
while (*current).getLink() != &null { | ||
count += 1; | ||
current = current.getLink(); | ||
} | ||
|
||
return count; | ||
} | ||
|
||
fn listSearch(head: *IntNode, target: int) -> *IntNode { | ||
let *current = head; | ||
|
||
while (*current).getLink() != &null { | ||
if (*current).getData() == target { | ||
return current; | ||
} | ||
current = current.getLink(); | ||
} | ||
|
||
return &null; | ||
} | ||
|
||
fn listRemoveNode(head: *IntNode, target: int) { | ||
// remove and free | ||
|
||
let *current = head; | ||
let *previous = &null; | ||
|
||
finally: | ||
try: | ||
// free memory after scope or error | ||
Allocator::free(current); | ||
catch: | ||
// a SegmentationFaultError is diffrent from a SIGSEGV | ||
// it is a safe way to handle segfaults as software errors | ||
// and not hardware errors like SIGSEGV. | ||
panic SegmentationFaultError("Failed to free memory"); | ||
|
||
while (*current).getLink() != &null { | ||
if (*current).getData() == target { | ||
(*previous).setLink((*current).getLink()); | ||
return; | ||
} | ||
|
||
previous = current; | ||
current = current.getLink(); | ||
} | ||
} | ||
|
||
fn main() { | ||
let head = IntNode(1, &null); | ||
let *tail = &head; | ||
|
||
for i in 2..100 { | ||
tail = tail.addNodeAfter(i); | ||
} | ||
|
||
let length: int = listLength(&head); | ||
let target: *IntNode? = listSearch(&head, 50); | ||
} | ||
|
||
|
Oops, something went wrong.