Compare commits
3 commits
Author | SHA1 | Date | |
---|---|---|---|
60ce82e68b | |||
f234dc1564 | |||
cb93fa917a |
14 changed files with 119 additions and 18 deletions
7
docs/LICENSE
Normal file
7
docs/LICENSE
Normal file
|
@ -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.
|
26
docs/README.md
Normal file
26
docs/README.md
Normal file
|
@ -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
|
|
@ -119,6 +119,7 @@ Példa: `kábel.halgass`
|
||||||
|Név|Leírás|Használat|Példa|
|
|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)`|
|
|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
|
:::warning
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ Példa: `kábel.halgass`
|
||||||
|Név|Leírás|Használat|Példa|
|
|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)`|
|
|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
|
:::warning
|
||||||
|
|
||||||
|
|
1
extension/.gitignore
vendored
Normal file
1
extension/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
build/
|
7
extension/LICENSE
Normal file
7
extension/LICENSE
Normal file
|
@ -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.
|
26
extension/README.md
Normal file
26
extension/README.md
Normal file
|
@ -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
|
Binary file not shown.
|
@ -66,6 +66,7 @@ vscode.languages.registerCompletionItemProvider('astrolang', {
|
||||||
"vége",
|
"vége",
|
||||||
|
|
||||||
"halgass",
|
"halgass",
|
||||||
|
"kapcsolódj",
|
||||||
"kérés",
|
"kérés",
|
||||||
"írj",
|
"írj",
|
||||||
"olvass",
|
"olvass",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"name": "astrolang-extension",
|
"name": "astrolang-extension",
|
||||||
"displayName": "Astro Lang",
|
"displayName": "Astro Lang",
|
||||||
"icon": "asl.png",
|
"icon": "asl.png",
|
||||||
"version": "1.0.0",
|
"version": "1.0.2",
|
||||||
"description": "The extension for Astro Lang",
|
"description": "The extension for Astro Lang",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Afonya",
|
"author": "Afonya",
|
||||||
|
|
|
@ -32,7 +32,8 @@ struct Compiled {
|
||||||
variables: Vec<Variable>,
|
variables: Vec<Variable>,
|
||||||
strings: HashMap<u32, String>,
|
strings: HashMap<u32, String>,
|
||||||
functions: HashMap<u32, Compiled>,
|
functions: HashMap<u32, Compiled>,
|
||||||
try_catch: Option<u32>
|
try_catch: Option<u32>,
|
||||||
|
ctx: Context
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -753,7 +754,8 @@ fn compile_function(ast: Vec<ASTPart>, args: Option<Vec<String>>, registers: &mu
|
||||||
variables,
|
variables,
|
||||||
strings,
|
strings,
|
||||||
functions,
|
functions,
|
||||||
try_catch
|
try_catch,
|
||||||
|
ctx: ctx.clone(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +827,7 @@ fn compile_body(compiled: Compiled, fpos: &mut usize, ctx: &Context) -> (Vec<u8>
|
||||||
*fpos += 1;
|
*fpos += 1;
|
||||||
append_be_num(&mut output, 3, *funcs as usize);
|
append_be_num(&mut output, 3, *funcs as usize);
|
||||||
append_be_num(&mut output, 4, *fpos);
|
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 {
|
for c in &mut context {
|
||||||
c.c_funcid = *fpos
|
c.c_funcid = *fpos
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,12 +436,12 @@ fn kabel_irj(machine: &mut Machine, op: &DecompiledOperation, args: Vec<VMMemory
|
||||||
if stream.is_none() {
|
if stream.is_none() {
|
||||||
error(String::from("Stream is not a TcpStream"), machine, op);
|
error(String::from("Stream is not a TcpStream"), machine, op);
|
||||||
}
|
}
|
||||||
let mut listener = stream.unwrap();
|
let mut stream = stream.unwrap();
|
||||||
let write = match &args[1] {
|
let write = match &args[1] {
|
||||||
VMMemory::String(s) => s.value.clone(),
|
VMMemory::String(s) => s.value.clone(),
|
||||||
_ => String::new()
|
_ => String::new()
|
||||||
};
|
};
|
||||||
match listener.write_all(write.as_bytes()) {
|
match stream.write_all(write.as_bytes()) {
|
||||||
Ok(_) => {},
|
Ok(_) => {},
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error(format!("Failed to write to stream: {}", e), machine, op);
|
error(format!("Failed to write to stream: {}", e), machine, op);
|
||||||
|
@ -540,6 +540,40 @@ fn kabel_keres(machine: &mut Machine, op: &DecompiledOperation, args: Vec<VMMemo
|
||||||
}
|
}
|
||||||
return VMMemory::Null(VMMemoryNull { variable_id: 0 });
|
return VMMemory::Null(VMMemoryNull { variable_id: 0 });
|
||||||
}
|
}
|
||||||
|
fn kabel_kapcsolodj(machine: &mut Machine, op: &DecompiledOperation, args: Vec<VMMemory>) -> 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<TableValue> = 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>) -> VMMemory {
|
fn kabel_halgass(machine: &mut Machine, op: &DecompiledOperation, args: Vec<VMMemory>) -> VMMemory {
|
||||||
arg_expect(&args, 0, "string", machine, op);
|
arg_expect(&args, 0, "string", machine, op);
|
||||||
arg_expect(&args, 1, "number", machine, op);
|
arg_expect(&args, 1, "number", machine, op);
|
||||||
|
@ -1161,6 +1195,10 @@ pub fn generate() -> HashMap<String, VMMemory> {
|
||||||
TableValue {
|
TableValue {
|
||||||
key: VMMemory::String(VMMemoryString { value: String::from("halgass"), variable_id: 0 }),
|
key: VMMemory::String(VMMemoryString { value: String::from("halgass"), variable_id: 0 }),
|
||||||
value: VMMemory::NativeFunction(VMMemoryNativeFunction { func: kabel_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 }));
|
mem.insert(String::from("kábel"), VMMemory::Table(VMMemoryTable { values: kabel, variable_id: 0 }));
|
||||||
|
|
|
@ -10,7 +10,7 @@ mod virtualmachine;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod decompiler;
|
mod decompiler;
|
||||||
|
|
||||||
const CLIVER: [u8; 3] = [1,0,0];
|
const CLIVER: [u8; 3] = [1,0,2];
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Context {
|
struct Context {
|
||||||
|
|
13
test.asl
13
test.asl
|
@ -1,11 +1,2 @@
|
||||||
lőcsve test() {
|
hámozd test be szaft"test2.asl"szaft
|
||||||
lőcsve toast() {
|
gethelj a = szaft"asd"szaft+1
|
||||||
ugass(2)
|
|
||||||
}
|
|
||||||
toast()
|
|
||||||
ugass(1)
|
|
||||||
}
|
|
||||||
gethelj k = krumpli.létrehoz(test)
|
|
||||||
ugass(krumpli.státusz(k))
|
|
||||||
krumpli.folytat(k)
|
|
||||||
ugass(krumpli.státusz(k))
|
|
Loading…
Add table
Add a link
Reference in a new issue