mirror of
https://github.com/erg-lang/erg.git
synced 2025-07-10 06:35:17 +00:00
50 lines
1.6 KiB
Rust
50 lines
1.6 KiB
Rust
use erg_common::error::{ErrorCore, ErrorKind::*, Location, SubMessage};
|
|
use erg_common::io::Input;
|
|
use erg_common::switch_lang;
|
|
|
|
use crate::error::*;
|
|
|
|
pub type EvalError = CompileError;
|
|
pub type EvalErrors = CompileErrors;
|
|
pub type EvalResult<T> = CompileResult<T>;
|
|
pub type SingleEvalResult<T> = SingleCompileResult<T>;
|
|
|
|
impl EvalError {
|
|
pub fn not_const_expr(input: Input, errno: usize, loc: Location, caused_by: String) -> Self {
|
|
Self::new(
|
|
ErrorCore::new(
|
|
vec![SubMessage::only_loc(loc)],
|
|
switch_lang!(
|
|
"japanese" => "定数式ではありません",
|
|
"simplified_chinese" => "不是常量表达式",
|
|
"traditional_chinese" => "不是常量表達式",
|
|
"english" => "not a constant expression",
|
|
),
|
|
errno,
|
|
NotConstExpr,
|
|
loc,
|
|
),
|
|
input,
|
|
caused_by,
|
|
)
|
|
}
|
|
|
|
pub fn invalid_literal(input: Input, errno: usize, loc: Location, caused_by: String) -> Self {
|
|
Self::new(
|
|
ErrorCore::new(
|
|
vec![SubMessage::only_loc(loc)],
|
|
switch_lang!(
|
|
"japanese" => "リテラルが不正です",
|
|
"simplified_chinese" => "字面量不合法",
|
|
"traditional_chinese" => "字面量不合法",
|
|
"english" => "invalid literal",
|
|
),
|
|
errno,
|
|
SyntaxError,
|
|
loc,
|
|
),
|
|
input,
|
|
caused_by,
|
|
)
|
|
}
|
|
}
|