Skip to content

Commit

Permalink
Remove the old pest parser code (FuelLabs#1407)
Browse files Browse the repository at this point in the history

* Remove selector debug which used the old parser

* remove sway-types dep on pest


Co-authored-by: mitchmindtree <[email protected]>

* remove friendly error string method
  • Loading branch information
sezna authored May 17, 2022
1 parent c253486 commit fd5ff42
Show file tree
Hide file tree
Showing 77 changed files with 364 additions and 6,404 deletions.
58 changes: 0 additions & 58 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions forc-pkg/src/pkg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ pub struct BuildPlan {
/// Parameters to pass through to the `sway_core::BuildConfig` during compilation.
pub struct BuildConfig {
pub use_orig_asm: bool,
pub use_orig_parser: bool,
pub print_ir: bool,
pub print_finalized_asm: bool,
pub print_intermediate_asm: bool,
Expand Down Expand Up @@ -943,7 +942,6 @@ pub fn sway_build_config(
manifest_dir.to_path_buf(),
)
.use_orig_asm(build_conf.use_orig_asm)
.use_orig_parser(build_conf.use_orig_parser)
.print_finalized_asm(build_conf.print_finalized_asm)
.print_intermediate_asm(build_conf.print_intermediate_asm)
.print_ir(build_conf.print_ir);
Expand Down Expand Up @@ -1204,7 +1202,7 @@ pub fn manifest_file_missing(dir: &Path) -> anyhow::Error {
pub fn parsing_failed(project_name: &str, errors: Vec<CompileError>) -> anyhow::Error {
let error = errors
.iter()
.map(|e| e.to_friendly_error_string())
.map(|e| format!("{}", e))
.collect::<Vec<String>>()
.join("\n");
let message = format!("Parsing {} failed: \n{}", project_name, error);
Expand Down
2 changes: 1 addition & 1 deletion forc-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ fn format_err(err: &sway_core::CompileError) {
let mut start_pos = span.start();
let mut end_pos = span.end();

let friendly_str = maybe_uwuify(&err.to_friendly_error_string());
let friendly_str = maybe_uwuify(&format!("{}", err));
let (snippet_title, snippet_slices) = if start_pos < end_pos {
let title = Some(Annotation {
label: None,
Expand Down
3 changes: 0 additions & 3 deletions forc/src/cli/commands/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ pub struct Command {
/// Whether to compile using the original (pre- IR) pipeline.
#[clap(long, hide = true)]
pub use_orig_asm: bool,
/// Whether to compile using the original (pest based) parser.
#[clap(long, hide = true)]
pub use_orig_parser: bool,
/// Whether to compile to bytecode (false) or to print out the generated ASM (true).
#[clap(long)]
pub print_finalized_asm: bool,
Expand Down
3 changes: 0 additions & 3 deletions forc/src/cli/commands/deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ pub struct Command {
/// Whether to compile using the original (pre- IR) pipeline.
#[clap(long, hide = true)]
pub use_orig_asm: bool,
/// Whether to compile using the original (pest based) parser.
#[clap(long, hide = true)]
pub use_orig_parser: bool,
/// Whether to compile to bytecode (false) or to print out the generated ASM (true).
#[clap(long)]
pub print_finalized_asm: bool,
Expand Down
4 changes: 0 additions & 4 deletions forc/src/cli/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ pub struct Command {
#[clap(long, hide = true)]
pub use_orig_asm: bool,

/// Whether to compile using the original (pest based) parser.
#[clap(long, hide = true)]
pub use_orig_parser: bool,

/// Only craft transaction and print it out.
#[clap(long)]
pub dry_run: bool,
Expand Down
2 changes: 0 additions & 2 deletions forc/src/ops/forc_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub fn build(command: BuildCommand) -> Result<pkg::Compiled> {
path,
binary_outfile,
use_orig_asm,
use_orig_parser,
debug_outfile,
print_finalized_asm,
print_intermediate_asm,
Expand All @@ -26,7 +25,6 @@ pub fn build(command: BuildCommand) -> Result<pkg::Compiled> {

let config = pkg::BuildConfig {
use_orig_asm,
use_orig_parser,
print_ir,
print_finalized_asm,
print_intermediate_asm,
Expand Down
2 changes: 0 additions & 2 deletions forc/src/ops/forc_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ pub async fn deploy(command: DeployCommand) -> Result<fuel_tx::ContractId> {
let DeployCommand {
path,
use_orig_asm,
use_orig_parser,
print_finalized_asm,
print_intermediate_asm,
print_ir,
Expand All @@ -40,7 +39,6 @@ pub async fn deploy(command: DeployCommand) -> Result<fuel_tx::ContractId> {
let build_command = BuildCommand {
path,
use_orig_asm,
use_orig_parser,
print_finalized_asm,
print_intermediate_asm,
print_ir,
Expand Down
1 change: 0 additions & 1 deletion forc/src/ops/forc_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ pub async fn run(command: RunCommand) -> Result<Vec<fuel_tx::Receipt>> {
let build_command = BuildCommand {
path: command.path,
use_orig_asm: command.use_orig_asm,
use_orig_parser: command.use_orig_parser,
print_finalized_asm: command.print_finalized_asm,
print_intermediate_asm: command.print_intermediate_asm,
print_ir: command.print_ir,
Expand Down
10 changes: 0 additions & 10 deletions sway-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ license = "Apache-2.0"
repository = "https://github.com/FuelLabs/sway"
description = "Sway core language."

[features]
selector-debug = ["clap", "hex"]

[dependencies]
clap = { version = "3.1", features = ["derive"], optional = true }
derivative = "2.2.0"
Expand All @@ -25,8 +22,6 @@ im = "15.0"
itertools = "0.10"
lazy_static = "1.4"
nanoid = "0.4"
pest = { version = "3.0.4", package = "fuel-pest" }
pest_derive = { version = "3.0.4", package = "fuel-pest_derive" }
petgraph = "0.6"
prettydiff = "0.5"
regex = "1"
Expand All @@ -38,8 +33,3 @@ sway-parse = { version = "0.12.2", path = "../sway-parse" }
sway-types = { version = "0.12.2", path = "../sway-types" }
sway-utils = { version = "0.12.2", path = "../sway-utils" }
thiserror = "1.0"

[[bin]]
name = "selector-debug"
path = "utils/selector_debug.rs"
required-features = ["selector-debug"]
2 changes: 1 addition & 1 deletion sway-core/src/asm_generation/expression/subfield.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
use crate::{
asm_lang::*,
error::*,
parse_tree::{AsmExpression, AsmOp, AsmRegisterDeclaration, CallPath, Literal, UnaryOp},
parse_tree::{AsmExpression, AsmOp, AsmRegisterDeclaration, CallPath, Literal},
semantic_analysis::{
ast_node::{
TypedAsmRegisterDeclaration, TypedCodeBlock, TypedEnumVariant, TypedExpressionVariant,
Expand Down
1 change: 0 additions & 1 deletion sway-core/src/asm_generation/from_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2286,7 +2286,6 @@ mod tests {
dir_of_code: std::sync::Arc::new("".into()),
manifest_path: std::sync::Arc::new("".into()),
use_orig_asm: false,
use_orig_parser: false,
print_intermediate_asm: false,
print_finalized_asm: false,
print_ir: false,
Expand Down
4 changes: 2 additions & 2 deletions sway-core/src/asm_generation/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
collections::{BTreeSet, HashMap},
fmt,
fmt::{self, Write},
};
use sway_types::Span;

Expand Down Expand Up @@ -448,7 +448,7 @@ impl fmt::Display for DataSection {
),
};
let data_label = DataId(ix as u32);
data_buf.push_str(&format!("{} {}\n", data_label, data_val));
writeln!(data_buf, "{} {}", data_label, data_val)?;
}

write!(f, ".data:\n{}", data_buf)
Expand Down
4 changes: 2 additions & 2 deletions sway-core/src/asm_lang/allocated_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::*;
use crate::asm_generation::DataSection;
use either::Either;
use fuel_asm::Opcode as VmOp;
use std::fmt;
use std::fmt::{self, Write};
use sway_types::span::Span;

const COMMENT_START_COLUMN: usize = 30;
Expand Down Expand Up @@ -280,7 +280,7 @@ impl fmt::Display for AllocatedOp {
while op_and_comment.len() < COMMENT_START_COLUMN {
op_and_comment.push(' ');
}
op_and_comment.push_str(&format!("; {}", self.comment))
write!(op_and_comment, "; {}", self.comment)?;
}

write!(fmtr, "{}", op_and_comment)
Expand Down
7 changes: 5 additions & 2 deletions sway-core/src/asm_lang/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ use crate::{asm_generation::DataId, error::*, parse_tree::AsmRegister, Ident};
use sway_types::span::Span;

use either::Either;
use std::{collections::HashSet, fmt};
use std::{
collections::HashSet,
fmt::{self, Write},
};

/// The column where the ; for comments starts
const COMMENT_START_COLUMN: usize = 40;
Expand Down Expand Up @@ -1464,7 +1467,7 @@ impl fmt::Display for Op {
while op_and_comment.len() < COMMENT_START_COLUMN {
op_and_comment.push(' ');
}
op_and_comment.push_str(&format!("; {}", self.comment))
write!(op_and_comment, "; {}", self.comment)?;
}

write!(fmtr, "{}", op_and_comment)
Expand Down
9 changes: 0 additions & 9 deletions sway-core/src/build_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub struct BuildConfig {
pub(crate) dir_of_code: Arc<PathBuf>,
pub(crate) manifest_path: Arc<PathBuf>,
pub(crate) use_orig_asm: bool,
pub(crate) use_orig_parser: bool,
pub(crate) print_intermediate_asm: bool,
pub(crate) print_finalized_asm: bool,
pub(crate) print_ir: bool,
Expand All @@ -31,7 +30,6 @@ impl BuildConfig {
dir_of_code: Arc::new(path),
manifest_path: Arc::new(canonicalized_manifest_path),
use_orig_asm: false,
use_orig_parser: false,
print_intermediate_asm: false,
print_finalized_asm: false,
print_ir: false,
Expand All @@ -46,13 +44,6 @@ impl BuildConfig {
}
}

pub fn use_orig_parser(self, a: bool) -> Self {
Self {
use_orig_parser: a,
..self
}
}

pub fn print_intermediate_asm(self, a: bool) -> Self {
Self {
print_intermediate_asm: a,
Expand Down
2 changes: 1 addition & 1 deletion sway-core/src/convert_parse_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2629,7 +2629,7 @@ fn path_type_to_type_info(
};
TypeInfo::ContractCaller {
abi_name,
address: String::new(),
address: None,
}
} else {
let type_arguments = match generics_opt {
Expand Down
Loading

0 comments on commit fd5ff42

Please sign in to comment.