fixed a bug where the character directly following a float literal would be ignored (because parsing the float accidentally used that character). this is what caused [12.5] to break.

This commit is contained in:
Dummi26 2023-04-15 16:01:34 +02:00
parent c484d2cbb2
commit ea5346f81c
2 changed files with 31 additions and 33 deletions

View File

@ -116,7 +116,7 @@ impl File {
&self.pos &self.pos
} }
pub fn get_ppos(&self) -> &FilePosition { pub fn get_ppos(&self) -> &FilePosition {
&self.pos &self.ppos
} }
pub fn set_pos(&mut self, pos: FilePosition) { pub fn set_pos(&mut self, pos: FilePosition) {
self.pos = pos; self.pos = pos;

View File

@ -593,6 +593,7 @@ fn parse_statement_adv(
let mut pot_float = String::new(); let mut pot_float = String::new();
for ch in &mut *file { for ch in &mut *file {
if ch.is_whitespace() || is_delimeter(ch) { if ch.is_whitespace() || is_delimeter(ch) {
file.set_pos(*file.get_ppos());
break; break;
} }
pot_float.push(ch); pot_float.push(ch);
@ -758,41 +759,38 @@ fn parse_function(
file.skip_whitespaces(); file.skip_whitespaces();
// find the arguments to the function // find the arguments to the function
let mut args = Vec::new(); let mut args = Vec::new();
loop { if let Some(')') = file.peek() {
match file.peek() { file.next();
Some(')') => { } else {
file.next();
break;
}
_ => (),
}
let mut arg_name = String::new();
loop { loop {
let err_fn_arg_name_start = *file.get_pos(); let mut arg_name = String::new();
match file.next() { loop {
Some(ch) if ch.is_whitespace() => break, let err_fn_arg_name_start = *file.get_pos();
Some(ch) => arg_name.push(ch), match file.next() {
None => { Some(ch) if ch.is_whitespace() => break,
return Err(ParseError { Some(ch) => arg_name.push(ch),
err: ParseErrors::FoundEofInFunctionArgName, None => {
location: err_fn_arg_name_start, return Err(ParseError {
location_end: Some(*file.get_pos()), err: ParseErrors::FoundEofInFunctionArgName,
context: vec![if let Some(err_fn_start) = err_fn_start { location: err_fn_arg_name_start,
( location_end: Some(*file.get_pos()),
format!("the function"), context: vec![if let Some(err_fn_start) = err_fn_start {
Some((err_fn_start, Some(*file.get_pos()))), (
) format!("the function"),
} else { Some((err_fn_start, Some(*file.get_pos()))),
(format!("not a real fn definition"), None) )
}], } else {
}) (format!("not a real fn definition"), None)
}],
})
}
} }
} }
} let (t, brk) = parse_type_adv(file, true)?;
let (t, brk) = parse_type_adv(file, true)?; args.push((arg_name, t));
args.push((arg_name, t)); if brk {
if brk { break;
break; }
} }
} }
Ok(SFunction::new(args, parse_block(file)?)) Ok(SFunction::new(args, parse_block(file)?))