Skip to content

Commit

Permalink
Fixed som_parser usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Hirevo committed Aug 5, 2020
1 parent 2c81280 commit bde4945
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 15 deletions.
7 changes: 3 additions & 4 deletions som-interpreter-bc/src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
8 changes: 1 addition & 7 deletions som-interpreter-bc/tests/basic_interpreter_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand Down Expand Up @@ -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 =
Expand Down
3 changes: 1 addition & 2 deletions som-parser-symbols/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClassDef> {
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.
Expand Down
3 changes: 1 addition & 2 deletions som-parser-text/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ClassDef> {
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.
Expand Down

0 comments on commit bde4945

Please sign in to comment.