fix tests
This commit is contained in:
parent
10eaa66a6d
commit
e02a95f065
@ -1,5 +1,5 @@
|
|||||||
use super::ast::var_binding::{Binding, ValBinding, VarBinding};
|
use super::ast::var_binding::{Binding, ValBinding, VarBinding};
|
||||||
use super::utils::{try_operator, try_token_type, parse_token_type};
|
use super::utils::{try_operator, parse_token_type};
|
||||||
use super::{expression, ParseResult};
|
use super::{expression, ParseResult};
|
||||||
use crate::error_handling::SyntaxError;
|
use crate::error_handling::SyntaxError;
|
||||||
use crate::lexic::token::{Token, TokenType};
|
use crate::lexic::token::{Token, TokenType};
|
||||||
@ -32,8 +32,15 @@ pub fn try_parse<'a>(tokens: &'a Vec<Token>, pos: usize) -> ParseResult<Binding,
|
|||||||
*/
|
*/
|
||||||
let (identifier, next_pos) = match parse_token_type(tokens, current_pos, TokenType::Identifier) {
|
let (identifier, next_pos) = match parse_token_type(tokens, current_pos, TokenType::Identifier) {
|
||||||
ParseResult::Ok(t, n) => (t, n),
|
ParseResult::Ok(t, n) => (t, n),
|
||||||
ParseResult::Err(error) => {
|
ParseResult::Mismatch(token) => {
|
||||||
// The parser found a token, but it's not an identifier
|
// The parser found a token, but it's not an identifier
|
||||||
|
return ParseResult::Err(SyntaxError {
|
||||||
|
error_start: token.position,
|
||||||
|
error_end: token.get_end_position(),
|
||||||
|
reason: "??".into(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
ParseResult::Err(error) => {
|
||||||
return ParseResult::Err(error);
|
return ParseResult::Err(error);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
@ -103,7 +110,7 @@ pub fn try_parse<'a>(tokens: &'a Vec<Token>, pos: usize) -> ParseResult<Binding,
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::lexic::get_tokens;
|
use crate::{lexic::get_tokens, syntax::utils::try_token_type};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn should_parse_val_binding() {
|
fn should_parse_val_binding() {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
error_handling::SyntaxError,
|
|
||||||
lexic::token::{Token, TokenType},
|
lexic::token::{Token, TokenType},
|
||||||
syntax::{ast::functions::FunctionCall, utils::parse_token_type, ParseResult},
|
syntax::{ast::functions::FunctionCall, utils::parse_token_type, ParseResult},
|
||||||
};
|
};
|
||||||
@ -23,7 +22,7 @@ pub fn try_parse<'a>(tokens: &'a Vec<Token>, pos: usize) -> ParseResult<Function
|
|||||||
current_pos = next_pos;
|
current_pos = next_pos;
|
||||||
|
|
||||||
// Parse arguments list
|
// Parse arguments list
|
||||||
let (args_list, next_pos) = match super::arguments_list::try_parse(tokens, current_pos) {
|
let (_args_list, next_pos) = match super::arguments_list::try_parse(tokens, current_pos) {
|
||||||
ParseResult::Ok(args, next) => (args, next),
|
ParseResult::Ok(args, next) => (args, next),
|
||||||
ParseResult::Err(err) => return ParseResult::Err(err),
|
ParseResult::Err(err) => return ParseResult::Err(err),
|
||||||
ParseResult::Mismatch(_) => {
|
ParseResult::Mismatch(_) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user