Compare commits

..

No commits in common. "4e3f1677be4f1d798ff33698d5875f67b83b50b1" and "56196551b89426633e754201c8f70b61093af32e" have entirely different histories.

3 changed files with 454 additions and 510 deletions

View File

@ -105,14 +105,12 @@ fn compile_statement(
register_count: usize, register_count: usize,
constants_table: &mut ConstantsTable, constants_table: &mut ConstantsTable,
) -> Result<Function, Diagnostics> { ) -> Result<Function, Diagnostics> {
let maybe_statement = parse_statement(input); let (maybe_statement, parse_diagnostics) = parse_statement(input);
if !maybe_statement.is_ok() { if !parse_diagnostics.is_empty() {
Err(maybe_statement.into_diagnostics()) Err(parse_diagnostics)
} else if let Some(statement) = maybe_statement {
session.compile_statement(&statement, register_count, constants_table)
} else { } else {
session.compile_statement( panic!("Unable to unwrap statement from previous input.")
&maybe_statement.into_inner(),
register_count,
constants_table,
)
} }
} }

View File

@ -118,10 +118,11 @@ impl<'a> Lexer<'a> {
} }
} }
if !terminated { if !terminated {
let err = return Some(Err(LexerError::new(
LexerError::new(self.position, end, LexerErrorKind::UnterminatedString); self.position,
self.position = end; end,
return Some(Err(err)); LexerErrorKind::UnterminatedString,
)));
} }
(end, TokenKind::String) (end, TokenKind::String)
} else { } else {
@ -136,13 +137,11 @@ impl<'a> Lexer<'a> {
} }
if prefix.len() == 0 { if prefix.len() == 0 {
let err = LexerError::new( return Some(Err(LexerError::new(
self.position, self.position,
self.position + 1, self.position + 1,
LexerErrorKind::UnrecognizedCharacter(chunk.chars().next().unwrap()), LexerErrorKind::UnrecognizedCharacter(chunk.chars().next().unwrap()),
); )));
self.position += 1;
return Some(Err(err));
} }
let token_kind = match prefix.as_str() { let token_kind = match prefix.as_str() {

File diff suppressed because it is too large Load Diff