1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00
This commit is contained in:
Natapat Samutpong 2022-03-13 14:22:53 +07:00
parent 873241ad94
commit a8e6dad433
4 changed files with 14 additions and 5 deletions

View file

@ -6,5 +6,6 @@ build-debug:
build-lib:
@echo "Building lib..."
rm -rf /usr/include/hazure/
cp ./lib/. /usr/include/hazure/ -r
@echo "Building lib... done"

View file

@ -39,6 +39,12 @@ Note: Everything in this project can be changed at anytime! (I'm still finding o
Lowerer(?) produce HIR
│ crates/hir
Type Checker (TODO)
│ │
│ ╰ Fail -> Print error -> Exit
Pass
Diagnostic(Lowering)
│ │ crates/diagnostic
│ ╰ Fail -> Print error -> Exit

View file

@ -65,8 +65,10 @@ impl Codegen {
match name.as_str() {
"write" => { format!("hazure_write({}){}\n", self.gen_ir(&args[0], false), semicolon!()) },
"read" => { format!("hazure_read(){}\n", semicolon!()) },
"write_file" => { format!("hazure_write({}){}\n", self.gen_ir(&args[0], false), semicolon!()) },
"read_file" => { format!("hazure_read_file({}){}\n", self.gen_ir(&args[0], false), semicolon!()) },
"time" => { format!("hazure_get_time(){}\n", semicolon!()) },
_ => unreachable!(format!("Unknown intrinsic: {}", name)) // Shoul be handled by lowering
}

View file

@ -5,7 +5,7 @@
template<typename T>
/**
* @brief Read the value from stdin and return it.
* Read the value from stdin and return it.
*/
T hazure_read() {
T x;
@ -15,8 +15,8 @@ T hazure_read() {
template<typename T>
/**
* @brief Prints the value of the variable to the stdout.
*
* Prints the value of the variable to the stdout.
*
* @param value The value to print.
*/
void hazure_write(T x) {
@ -24,7 +24,7 @@ void hazure_write(T x) {
}
/*
* @brief Read the value from the file and return it.
* Read the value from the file and return it.
*
* @param file_name The name of the file to read from.
* @return std::string The value read from the file.
@ -37,7 +37,7 @@ std::string hazure_read_file(std::string filename) {
}
/*
* @brief Write string to file.
* Write string to file.
*
* @param filename The file name to write to.
* @param content The content to write.