From 7d4887c669bd787e26359514606d2b28d08b3e1e Mon Sep 17 00:00:00 2001 From: dalance Date: Tue, 9 Jul 2019 14:15:37 +0900 Subject: [PATCH] Remove temporary parsers --- .../looping_statements.rs | 4 +- src/parser/source_text/constraints.rs | 2 +- src/parser/specify_section/mod.rs | 2 + .../specify_section/specify_path_delays.rs | 18 ++++ src/parser/utils.rs | 97 ++----------------- 5 files changed, 30 insertions(+), 93 deletions(-) create mode 100644 src/parser/specify_section/specify_path_delays.rs diff --git a/src/parser/behavioral_statements/looping_statements.rs b/src/parser/behavioral_statements/looping_statements.rs index 48437a4..57d27f1 100644 --- a/src/parser/behavioral_statements/looping_statements.rs +++ b/src/parser/behavioral_statements/looping_statements.rs @@ -77,7 +77,7 @@ pub struct Var {} #[derive(Debug)] pub enum ForStepAssignment<'a> { Operator(OperatorAssignment<'a>), - IncOrDec(IncOrDecDeclaration<'a>), + IncOrDec(IncOrDecExpression<'a>), Subroutine(SubroutineCall<'a>), } @@ -213,7 +213,7 @@ pub fn for_step(s: &str) -> IResult<&str, Vec> { pub fn for_step_assignment(s: &str) -> IResult<&str, ForStepAssignment> { alt(( map(operator_assignment, |x| ForStepAssignment::Operator(x)), - map(inc_or_dec_declaration, |x| ForStepAssignment::IncOrDec(x)), + map(inc_or_dec_expression, |x| ForStepAssignment::IncOrDec(x)), map(function_subroutine_call, |x| { ForStepAssignment::Subroutine(x) }), diff --git a/src/parser/source_text/constraints.rs b/src/parser/source_text/constraints.rs index c57489c..ba069ef 100644 --- a/src/parser/source_text/constraints.rs +++ b/src/parser/source_text/constraints.rs @@ -19,7 +19,7 @@ pub struct ConstraintDeclaration<'a> { pub struct Static {} #[derive(Debug)] -pub struct ConstraintsBlock<'a> { +pub struct ConstraintBlock<'a> { pub nodes: (Vec>,), } diff --git a/src/parser/specify_section/mod.rs b/src/parser/specify_section/mod.rs index 39cdce5..4c4eb12 100644 --- a/src/parser/specify_section/mod.rs +++ b/src/parser/specify_section/mod.rs @@ -1,4 +1,6 @@ pub mod specify_block_declaration; pub mod specify_block_terminals; +pub mod specify_path_delays; pub use specify_block_declaration::*; pub use specify_block_terminals::*; +pub use specify_path_delays::*; diff --git a/src/parser/specify_section/specify_path_delays.rs b/src/parser/specify_section/specify_path_delays.rs new file mode 100644 index 0000000..b4b5ef9 --- /dev/null +++ b/src/parser/specify_section/specify_path_delays.rs @@ -0,0 +1,18 @@ +use crate::parser::*; +//use nom::branch::*; +//use nom::combinator::*; +use nom::error::*; +use nom::{Err, IResult}; + +// ----------------------------------------------------------------------------- + +#[derive(Debug)] +pub struct EdgeIdentifier<'a> { + pub nodes: (Identifier<'a>,), +} + +// ----------------------------------------------------------------------------- + +pub fn edge_identifier(s: &str) -> IResult<&str, EdgeIdentifier> { + Err(Err::Error(make_error(s, ErrorKind::Fix))) +} diff --git a/src/parser/utils.rs b/src/parser/utils.rs index 086212d..e49e14d 100644 --- a/src/parser/utils.rs +++ b/src/parser/utils.rs @@ -6,6 +6,13 @@ use nom::IResult; // ----------------------------------------------------------------------------- +#[derive(Debug)] +pub struct Symbol<'a> { + pub nodes: (&'a str,), +} + +// ----------------------------------------------------------------------------- + pub fn ws<'a, O, F>(f: F) -> impl Fn(&'a str) -> IResult<&'a str, O> where F: Fn(&'a str) -> IResult<&'a str, O>, @@ -70,94 +77,4 @@ where } } -#[derive(Debug)] -pub struct Symbol<'a> { - pub nodes: (&'a str,), -} - // ----------------------------------------------------------------------------- - -#[derive(Debug)] -pub struct ConstraintBlock<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct EdgeIdentifier<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct IncOrDecDeclaration<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct CheckerInstantiation<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct DataDeclaration<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct ModuleOrGenerateItem<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct InterfaceOrGenerateItem<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct CheckerOrGenerateItem<'a> { - pub raw: Vec<&'a str>, -} - -#[derive(Debug)] -pub struct RandomQualifier<'a> { - pub raw: Vec<&'a str>, -} - -pub fn constraint_block(s: &str) -> IResult<&str, ConstraintBlock> { - Ok((s, ConstraintBlock { raw: vec![] })) -} - -pub fn identifier_list(s: &str) -> IResult<&str, Vec> { - Ok((s, vec![])) -} - -pub fn edge_identifier(s: &str) -> IResult<&str, EdgeIdentifier> { - Ok((s, EdgeIdentifier { raw: vec![] })) -} - -pub fn inc_or_dec_declaration(s: &str) -> IResult<&str, IncOrDecDeclaration> { - Ok((s, IncOrDecDeclaration { raw: vec![] })) -} - -pub fn checker_instantiation(s: &str) -> IResult<&str, CheckerInstantiation> { - Ok((s, CheckerInstantiation { raw: vec![] })) -} - -pub fn data_declaration(s: &str) -> IResult<&str, DataDeclaration> { - Ok((s, DataDeclaration { raw: vec![] })) -} - -pub fn module_or_generate_item(s: &str) -> IResult<&str, ModuleOrGenerateItem> { - Ok((s, ModuleOrGenerateItem { raw: vec![] })) -} - -pub fn interface_or_generate_item(s: &str) -> IResult<&str, InterfaceOrGenerateItem> { - Ok((s, InterfaceOrGenerateItem { raw: vec![] })) -} - -pub fn checker_or_generate_item(s: &str) -> IResult<&str, CheckerOrGenerateItem> { - Ok((s, CheckerOrGenerateItem { raw: vec![] })) -} - -pub fn random_qualifier(s: &str) -> IResult<&str, RandomQualifier> { - Ok((s, RandomQualifier { raw: vec![] })) -}