integrate ast::Location into compilre-core::Location

This commit is contained in:
Jeong YunWon 2022-08-22 08:38:21 +09:00
parent bfac0355dc
commit 904fc477f1
8 changed files with 21 additions and 83 deletions

View file

@ -1,12 +1,9 @@
//! Define internal parse error types
//! The goal is to provide a matching and a safe error API, maksing errors from LALR
use crate::{ast::Location, token::Tok};
use lalrpop_util::ParseError as LalrpopError;
use crate::ast::Location;
use crate::token::Tok;
use std::error::Error;
use std::fmt;
use std::{error::Error, fmt};
/// Represents an error during lexical scanning.
#[derive(Debug, PartialEq)]
@ -186,7 +183,7 @@ impl ParseError {
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{} at {}", self.error, self.location)
self.location.fmt_with(f, &self.error)
}
}

View file

@ -1,8 +1,7 @@
use ahash::RandomState;
use std::collections::HashSet;
use crate::ast;
use crate::error::{LexicalError, LexicalErrorType};
use ahash::RandomState;
use std::collections::HashSet;
pub struct ArgumentList {
pub args: Vec<ast::Expr>,

View file

@ -5,13 +5,9 @@
//! parse a whole program, a single statement, or a single
//! expression.
use std::iter;
use crate::ast;
use crate::error::ParseError;
use crate::lexer;
pub use crate::mode::Mode;
use crate::python;
use crate::{ast, error::ParseError, lexer, python};
use std::iter;
/*
* Parse python code.