added multiline tables
This commit is contained in:
parent
b4f930d1c5
commit
12d3250bc4
4 changed files with 18 additions and 7 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue