Skip to content

Commit

Permalink
Replace old parser with new
Browse files Browse the repository at this point in the history
  • Loading branch information
sbillig committed Jun 21, 2024
1 parent 045421e commit c630bdf
Show file tree
Hide file tree
Showing 33 changed files with 273 additions and 2,271 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ members = [
"crates/ir",
"crates/codegen",
"crates/object",
"crates/parser2",
"crates/parser",
"crates/filecheck",
"crates/triple",
"crates/interpreter",
Expand Down
2 changes: 1 addition & 1 deletion crates/filecheck/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ publish = false
filecheck = "0.5.0" # { path = "/Users/sean/src/filecheck" }
sonatina-ir = { path = "../ir" }
sonatina-codegen = { path = "../codegen" }
sonatina-parser2 = { path = "../parser2" }
sonatina-parser = { path = "../parser" }
termcolor = "1.1.2"
walkdir = "2"
2 changes: 1 addition & 1 deletion crates/filecheck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{

use sonatina_ir::{ir_writer::FuncWriter, module::FuncRef, Function};

use sonatina_parser2::{parse_module, ParsedModule};
use sonatina_parser::{parse_module, ParsedModule};
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
use walkdir::WalkDir;

Expand Down
2 changes: 1 addition & 1 deletion crates/interpreter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ cranelift-entity = "0.104"
sonatina-ir = { path = "../ir", version = "0.0.3-alpha" }

[dev-dependencies]
sonatina-parser2 = { path = "../parser2" }
sonatina-parser = { path = "../parser" }
2 changes: 1 addition & 1 deletion crates/interpreter/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ mod test {
use super::*;

fn parse_module(input: &str) -> Module {
match sonatina_parser2::parse_module(input) {
match sonatina_parser::parse_module(input) {
Ok(pm) => pm.module,
Err(errs) => {
for err in errs {
Expand Down
18 changes: 15 additions & 3 deletions crates/parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@ description = "Parser for sonatina-ir text format"
categories = ["compilers", "parser", "wasm"]
keywords = ["compiler", "evm", "wasm", "smart-contract"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
sonatina-ir = { path = "../ir", version = "0.0.3-alpha" }
ir = { package = "sonatina-ir", path = "../ir", version = "0.0.3-alpha" }
sonatina-triple = { path = "../triple", version = "0.0.3-alpha" }
smallvec = "1.7.0"
cranelift-entity = "0.104"
pest = "2.7.10"
pest_derive = "2.7.10"
pest-ast = "0.3.4"
from-pest = "0.3.2"
smol_str = "0.2.2"
hex = "0.4.3"
num-traits = { version = "0.2.19", default-features = false }
either = { version = "1.12.0", default-features = false }
annotate-snippets = "0.11.4"

[dev-dependencies]
dir-test = { git = "https://github.com/sbillig/dir-test", rev = "c4115dd" }
insta = { version = "1.38.0" }
indenter = "0.3.3"
10 changes: 1 addition & 9 deletions crates/parser2/src/ast.rs → crates/parser/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use super::syntax::Node;
use super::{syntax::Node, Error};
use crate::syntax::{FromSyntax, Parser, Rule};
use annotate_snippets::{Level, Renderer, Snippet};
use either::Either;
Expand All @@ -13,14 +13,6 @@ use smol_str::SmolStr;
pub use sonatina_triple::{InvalidTriple, TargetTriple};
use std::{io, ops::Range, str::FromStr};

#[derive(Debug)]
#[allow(clippy::large_enum_variant)]
pub enum Error {
NumberOutOfBounds(Range<usize>),
InvalidTarget(InvalidTriple, Range<usize>),
SyntaxError(pest::error::Error<Rule>),
}

pub fn parse(input: &str) -> Result<Module, Vec<Error>> {
pest::set_error_detail(true); // xxx

Expand Down
Loading

0 comments on commit c630bdf

Please sign in to comment.