diff --git a/som-interpreter-bc/src/shell.rs b/som-interpreter-bc/src/shell.rs index 4efd47f6..cfd30226 100644 --- a/som-interpreter-bc/src/shell.rs +++ b/som-interpreter-bc/src/shell.rs @@ -6,7 +6,6 @@ use anyhow::Error; use som_lexer::{Lexer, Token}; use som_parser::lang; -use som_parser::Parser; use som_interpreter_bc::compiler; use som_interpreter_bc::frame::FrameKind; @@ -64,9 +63,9 @@ pub fn interactive( } let start = Instant::now(); - let class_def = match lang::class_def().parse(tokens.as_slice()) { - Some((expr, rest)) if rest.is_empty() => expr, - Some(_) | None => { + let class_def = match som_parser::apply(lang::class_def(), tokens.as_slice()) { + Some(class_def) => class_def, + None => { println!("ERROR: could not fully parse the given expression"); continue; } diff --git a/som-interpreter-bc/tests/basic_interpreter_tests.rs b/som-interpreter-bc/tests/basic_interpreter_tests.rs index b384b610..1637e94b 100644 --- a/som-interpreter-bc/tests/basic_interpreter_tests.rs +++ b/som-interpreter-bc/tests/basic_interpreter_tests.rs @@ -7,7 +7,6 @@ use som_interpreter_bc::universe::Universe; use som_interpreter_bc::value::Value; use som_lexer::{Lexer, Token}; use som_parser::lang; -use som_parser::Parser; fn setup_universe() -> Universe { let classpath = vec![ @@ -140,12 +139,7 @@ fn basic_interpreter_tests() { "could not fully tokenize test expression" ); - let (class_def, rest) = lang::class_def().parse(tokens.as_slice()).unwrap(); - assert!( - rest.is_empty(), - "could not fully parse test expression: {:?}", - rest - ); + let class_def = som_parser::apply(lang::class_def(), tokens.as_slice()).unwrap(); let object_class = universe.object_class(); let class = diff --git a/som-parser-symbols/src/lib.rs b/som-parser-symbols/src/lib.rs index f586c2f3..a4d3aa14 100644 --- a/som-parser-symbols/src/lib.rs +++ b/som-parser-symbols/src/lib.rs @@ -13,8 +13,7 @@ use som_parser_core::Parser; /// Parses the input of an entire file into an AST. pub fn parse_file(input: &[Token]) -> Option { - let (class, _) = lang::file().parse(input)?; - Some(class) + self::apply(lang::file(), input) } /// Applies a parser and returns the output value if the entirety of the input has been parsed successfully. diff --git a/som-parser-text/src/lib.rs b/som-parser-text/src/lib.rs index 957a4fb5..eb5659e0 100644 --- a/som-parser-text/src/lib.rs +++ b/som-parser-text/src/lib.rs @@ -12,8 +12,7 @@ use som_parser_core::Parser; /// Parses the input of an entire file into an AST. pub fn parse_file(input: &[char]) -> Option { - let (class, _) = lang::file().parse(input)?; - Some(class) + self::apply(lang::file(), input) } /// Applies a parser and returns the output value if the entirety of the input has been parsed successfully.