mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 12:24:45 +00:00
Merge branch 'main' of https://github.com/erg-lang/erg
This commit is contained in:
commit
e1be2d2b51
8 changed files with 33 additions and 41 deletions
|
@ -5,7 +5,6 @@ use erg_common::cache::CacheSet;
|
|||
use erg_common::config::ErgConfig;
|
||||
use erg_common::config::Input;
|
||||
use erg_common::traits::{Locational, Runnable, Stream};
|
||||
use erg_common::Str;
|
||||
use erg_common::{debug_power_assert, fn_name_full, normalize_newline, switch_lang};
|
||||
|
||||
use crate::error::{LexError, LexErrors, LexResult, LexerRunnerError, LexerRunnerErrors};
|
||||
|
@ -47,7 +46,7 @@ impl Runnable for LexerRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn eval(&mut self, src: Str) -> Result<String, LexerRunnerErrors> {
|
||||
fn eval(&mut self, src: String) -> Result<String, LexerRunnerErrors> {
|
||||
let lexer = Lexer::from_str(src);
|
||||
if cfg!(feature = "debug") {
|
||||
let ts = lexer
|
||||
|
@ -97,7 +96,7 @@ impl Lexer /*<'a>*/ {
|
|||
}
|
||||
|
||||
#[allow(clippy::should_implement_trait)]
|
||||
pub fn from_str(src: Str) -> Self {
|
||||
pub fn from_str(src: String) -> Self {
|
||||
let escaped = normalize_newline(&src);
|
||||
Lexer {
|
||||
str_cache: CacheSet::new(),
|
||||
|
|
|
@ -194,7 +194,7 @@ impl Runnable for ParserRunner {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn eval(&mut self, src: Str) -> Result<String, ParserRunnerErrors> {
|
||||
fn eval(&mut self, src: String) -> Result<String, ParserRunnerErrors> {
|
||||
let ast = self.parse_with_input(src)?;
|
||||
Ok(format!("{ast}"))
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ impl ParserRunner {
|
|||
self_.parse()
|
||||
}
|
||||
|
||||
fn parse_with_input(&mut self, src: Str) -> Result<AST, ParserRunnerErrors> {
|
||||
fn parse_with_input(&mut self, src: String) -> Result<AST, ParserRunnerErrors> {
|
||||
let ts = Lexer::new(Input::Str(src))
|
||||
.lex()
|
||||
.map_err(|errs| ParserRunnerErrors::convert(self.input(), errs))?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue