diff --git a/docs/LICENSE b/docs/LICENSE new file mode 100644 index 0000000..e66f844 --- /dev/null +++ b/docs/LICENSE @@ -0,0 +1,7 @@ +Copyright 2025 Afonya + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..da94e10 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,26 @@ +# Astro Lang Docs +Egy magyar + GenZ programozási nyelv + +--- + +## Miben jobb: +- többszavas változók +- magyar kulcsszavak +- teljes értékű dokumentáció +- Rustban írt + +--- + +## Példa: +```asl +gethelj a = 10 +ugass(a) +``` + +--- + +Weboldal és dokumentáció: [itt](https://astrolang.afonyanet.hu) + +Kiadások: [itt](https://git.afonyanet.hu/afonya/AstroLang/releases) + +Licensz: MIT \ No newline at end of file diff --git a/docs/docs/enviroment.md b/docs/docs/enviroment.md index 54e6b31..893e3fc 100644 --- a/docs/docs/enviroment.md +++ b/docs/docs/enviroment.md @@ -119,6 +119,7 @@ Példa: `kábel.halgass` |Név|Leírás|Használat|Példa| |---|---|---|---| |halgass|Hallgat egy porton.|`halgass(host: string, port: number): halgató`|`halgass(szaft"0.0.0.0"szaft,1010)`| +|kapcsolódj|Rákapcsolódik egy célra.|`kapcsolódj(target: string): kapcsolat`|`kapcsolódj(szaft"example.com:80"szaft)`| :::warning diff --git a/docs/versioned_docs/version-1.0.0/enviroment.md b/docs/versioned_docs/version-1.0.0/enviroment.md index 54e6b31..893e3fc 100644 --- a/docs/versioned_docs/version-1.0.0/enviroment.md +++ b/docs/versioned_docs/version-1.0.0/enviroment.md @@ -119,6 +119,7 @@ Példa: `kábel.halgass` |Név|Leírás|Használat|Példa| |---|---|---|---| |halgass|Hallgat egy porton.|`halgass(host: string, port: number): halgató`|`halgass(szaft"0.0.0.0"szaft,1010)`| +|kapcsolódj|Rákapcsolódik egy célra.|`kapcsolódj(target: string): kapcsolat`|`kapcsolódj(szaft"example.com:80"szaft)`| :::warning diff --git a/extension/.gitignore b/extension/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/extension/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/extension/LICENSE b/extension/LICENSE new file mode 100644 index 0000000..e66f844 --- /dev/null +++ b/extension/LICENSE @@ -0,0 +1,7 @@ +Copyright 2025 Afonya + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/extension/README.md b/extension/README.md new file mode 100644 index 0000000..7ddfcf8 --- /dev/null +++ b/extension/README.md @@ -0,0 +1,26 @@ +# Astro Lang Extension +Egy magyar + GenZ programozási nyelv + +--- + +## Miben jobb: +- többszavas változók +- magyar kulcsszavak +- teljes értékű dokumentáció +- Rustban írt + +--- + +## Példa: +```asl +gethelj a = 10 +ugass(a) +``` + +--- + +Weboldal és dokumentáció: [itt](https://astrolang.afonyanet.hu) + +Kiadások: [itt](https://git.afonyanet.hu/afonya/AstroLang/releases) + +Licensz: MIT \ No newline at end of file diff --git a/extension/astrolang-extension-1.0.0.vsix b/extension/astrolang-extension-1.0.2.vsix similarity index 75% rename from extension/astrolang-extension-1.0.0.vsix rename to extension/astrolang-extension-1.0.2.vsix index 6170be4..0651d87 100644 Binary files a/extension/astrolang-extension-1.0.0.vsix and b/extension/astrolang-extension-1.0.2.vsix differ diff --git a/extension/index.js b/extension/index.js index e9adb88..c07fe37 100644 --- a/extension/index.js +++ b/extension/index.js @@ -66,6 +66,7 @@ vscode.languages.registerCompletionItemProvider('astrolang', { "vége", "halgass", + "kapcsolódj", "kérés", "írj", "olvass", diff --git a/extension/package.json b/extension/package.json index 6f0101d..36ff78e 100644 --- a/extension/package.json +++ b/extension/package.json @@ -2,7 +2,7 @@ "name": "astrolang-extension", "displayName": "Astro Lang", "icon": "asl.png", - "version": "1.0.0", + "version": "1.0.2", "description": "The extension for Astro Lang", "license": "MIT", "author": "Afonya", diff --git a/src/compiler.rs b/src/compiler.rs index d30d014..49110e5 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -32,7 +32,8 @@ struct Compiled { variables: Vec, strings: HashMap, functions: HashMap, - try_catch: Option + try_catch: Option, + ctx: Context } #[derive(Debug, Clone)] @@ -753,7 +754,8 @@ fn compile_function(ast: Vec, args: Option>, registers: &mu variables, strings, functions, - try_catch + try_catch, + ctx: ctx.clone(), }; } @@ -825,7 +827,7 @@ fn compile_body(compiled: Compiled, fpos: &mut usize, ctx: &Context) -> (Vec *fpos += 1; append_be_num(&mut output, 3, *funcs as usize); append_be_num(&mut output, 4, *fpos); - let (compiled, mut context) = compile_body(compiled.functions[funcs].clone(), fpos, ctx); + let (compiled, mut context) = compile_body(compiled.functions[funcs].clone(), fpos, &compiled.functions[funcs].ctx); for c in &mut context { c.c_funcid = *fpos } diff --git a/src/enviroment.rs b/src/enviroment.rs index 40cfb12..4a99d64 100644 --- a/src/enviroment.rs +++ b/src/enviroment.rs @@ -436,12 +436,12 @@ fn kabel_irj(machine: &mut Machine, op: &DecompiledOperation, args: Vec s.value.clone(), _ => String::new() }; - match listener.write_all(write.as_bytes()) { + match stream.write_all(write.as_bytes()) { Ok(_) => {}, Err(e) => { error(format!("Failed to write to stream: {}", e), machine, op); @@ -540,6 +540,40 @@ fn kabel_keres(machine: &mut Machine, op: &DecompiledOperation, args: Vec) -> VMMemory { + arg_expect(&args, 0, "string", machine, op); + let str = match &args[0] { + VMMemory::String(s) => s.value.clone(), + _ => String::new() + }; + let stream = match TcpStream::connect(&str) { + Ok(s) => s, + Err(err) => { + error(format!("Failed to connect to {}: {}", str, err), machine, op); + return VMMemory::Null(VMMemoryNull { variable_id: 0 }); + } + }; + machine.storage.push(Box::new(stream)); + let ret_table: Vec = vec![ + TableValue { + key: VMMemory::String(VMMemoryString { value: String::from("olvass"), variable_id: 0 }), + value: VMMemory::NativeFunction(VMMemoryNativeFunction { func: kabel_olvass, variable_id: 0 }), + }, + TableValue { + key: VMMemory::String(VMMemoryString { value: String::from("írj"), variable_id: 0 }), + value: VMMemory::NativeFunction(VMMemoryNativeFunction { func: kabel_irj, variable_id: 0 }), + }, + TableValue { + key: VMMemory::String(VMMemoryString { value: String::from("zár"), variable_id: 0 }), + value: VMMemory::NativeFunction(VMMemoryNativeFunction { func: kabel_zar, variable_id: 0 }), + }, + TableValue { + key: VMMemory::String(VMMemoryString { value: String::from("id"), variable_id: 0 }), + value: VMMemory::Number(VMMemoryNumber { value: (machine.storage.len()-1) as f64, variable_id: 0 }), + } + ]; + return VMMemory::Table(VMMemoryTable { values: ret_table, variable_id: 0 }); +} fn kabel_halgass(machine: &mut Machine, op: &DecompiledOperation, args: Vec) -> VMMemory { arg_expect(&args, 0, "string", machine, op); arg_expect(&args, 1, "number", machine, op); @@ -1161,6 +1195,10 @@ pub fn generate() -> HashMap { TableValue { key: VMMemory::String(VMMemoryString { value: String::from("halgass"), variable_id: 0 }), value: VMMemory::NativeFunction(VMMemoryNativeFunction { func: kabel_halgass, variable_id: 0 }), + }, + TableValue { + key: VMMemory::String(VMMemoryString { value: String::from("kapcsolódj"), variable_id: 0 }), + value: VMMemory::NativeFunction(VMMemoryNativeFunction { func: kabel_kapcsolodj, variable_id: 0 }), } ]; mem.insert(String::from("kábel"), VMMemory::Table(VMMemoryTable { values: kabel, variable_id: 0 })); diff --git a/src/main.rs b/src/main.rs index 3de6c12..0b758b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ mod virtualmachine; mod errors; mod decompiler; -const CLIVER: [u8; 3] = [1,0,0]; +const CLIVER: [u8; 3] = [1,0,2]; #[derive(Debug, Clone)] struct Context { diff --git a/test.asl b/test.asl index 5b5aa9a..3324140 100644 --- a/test.asl +++ b/test.asl @@ -1,11 +1,2 @@ -lőcsve test() { - lőcsve toast() { - ugass(2) - } - toast() - ugass(1) -} -gethelj k = krumpli.létrehoz(test) -ugass(krumpli.státusz(k)) -krumpli.folytat(k) -ugass(krumpli.státusz(k)) \ No newline at end of file +hámozd test be szaft"test2.asl"szaft +gethelj a = szaft"asd"szaft+1 \ No newline at end of file