added multiline tables

This commit is contained in:
afonya2 2025-06-11 17:00:22 +02:00
parent b4f930d1c5
commit 12d3250bc4
Signed by: afonya
GPG key ID: EBB9C4CAFAAFB2DC
4 changed files with 18 additions and 7 deletions

View file

@ -641,7 +641,6 @@ fn do_ast_op(ast_op: ASTPart, op_count: &mut usize, ops: &mut Vec<Operation>, va
process::exit(1);
}
}
},
_ => {}
}

View file

@ -369,15 +369,23 @@ fn read_function(input: &Vec<Token>, pos: &mut usize, with_args: bool, ctx: &Con
fn read_table(input: &Vec<Token>, pos: &mut usize, ctx: &Context) -> ASTPart {
let start_pos = input[*pos].pos;
let key_ends: Vec<Token> = vec![
Token { typ: TokenType::SEPARATOR, value: String::from("]"), pos: 0 }
Token { typ: TokenType::SEPARATOR, value: String::from("]"), pos: 0 },
];
let ends: Vec<Token> = vec![
Token { typ: TokenType::SEPARATOR, value: String::from("}"), pos: 0 },
Token { typ: TokenType::SEPARATOR, value: String::from(","), pos: 0 }
Token { typ: TokenType::SEPARATOR, value: String::from(","), pos: 0 },
Token { typ: TokenType::OPEND, value: String::from("\n"), pos: 0 },
];
let mut tbl: Vec<TableValue> = vec![];
let mut key = 0;
while *pos < input.len() {
if input[*pos].typ == TokenType::OPEND && input[*pos].value == "\n" {
*pos += 1;
continue;
} else if input[*pos].typ == TokenType::SEPARATOR && input[*pos].value == "}" {
*pos += 1;
break;
}
if input[*pos].typ == TokenType::SEPARATOR && input[*pos].value == "[" {
*pos += 1;
let keyy = read_exp(pos, input, &key_ends, &key_ends, ctx);
@ -419,6 +427,9 @@ fn read_table(input: &Vec<Token>, pos: &mut usize, ctx: &Context) -> ASTPart {
} else if input[*pos].typ == TokenType::SEPARATOR && input[*pos].value == "," {
*pos += 1;
continue;
} else if input[*pos].typ == TokenType::OPEND && input[*pos].value == "\n" {
*pos += 1;
continue;
} else {
let err = create_error(&format!("Unexpected end of table"), input[*pos].pos, ErrorType::SyntaxError, ErrorSubType::UnexpectedEnd);
print_error(&err, &ctx);

View file

@ -1,2 +1,5 @@
hámozd test be szaft"test2.asl"szaft
ugass(test)
gethelj a = {
[szaft"test"szaft] = szaft"test"szaft,
[szaft"teher"szaft] = szaft"teher"szaft
}
ugass(a)

View file

@ -1,2 +0,0 @@
ugass(szaft"Hell yeah!"szaft)
reti 1