From 5284760090083c85663d3ced756028c33b10ecb1 Mon Sep 17 00:00:00 2001 From: Guojie Luo Date: Thu, 24 Feb 2022 10:07:54 +0800 Subject: [PATCH] Make minor updates --- src/cst/always_statement.rs | 5 ++++- src/cst/conditional_statement.rs | 14 +++++++++----- src/cst/tags.rs | 18 +++++++++++++----- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/cst/always_statement.rs b/src/cst/always_statement.rs index a4027ff..1580613 100644 --- a/src/cst/always_statement.rs +++ b/src/cst/always_statement.rs @@ -31,7 +31,10 @@ impl AlwaysStatement { ProceduralTimingControlStatement::codegen(json_statement, context); } Some(Tag::ALWAYS_COMB) => { - panic!(); // FIXME + println!("TODO: implmenent AlwaysComb::codegen()"); + } + Some(x) => { + println!("FIXME: missing {}", x); } _ => { panic!(); diff --git a/src/cst/conditional_statement.rs b/src/cst/conditional_statement.rs index 7f3bf5f..b63da66 100644 --- a/src/cst/conditional_statement.rs +++ b/src/cst/conditional_statement.rs @@ -1,4 +1,4 @@ -use crate::cst::{Expression, ModuleContext, Tag, Tools}; +use crate::cst::{Expression, ModuleContext, Statement, Tag, Tools}; use json::JsonValue; pub struct ConditionalStatement {} @@ -35,11 +35,15 @@ impl ConditionalStatement { } } - fn visit_if_body(_json: &JsonValue, _context: &ModuleContext) { - println!("TODO: implement ConditionalStatement::visit_if_body()"); + fn visit_if_body(json: &JsonValue, context: &ModuleContext) { + let json_nodes = &json["children"]; + assert_eq!(json_nodes.len(), 1); + Statement::codegen(&json_nodes[0], context); } - fn visit_else_body(_json: &JsonValue, _context: &ModuleContext) { - println!("TODO: implement ConditionalStatement::visit_else_body()"); + fn visit_else_body(json: &JsonValue, context: &ModuleContext) { + let json_nodes = &json["children"]; + assert_eq!(json_nodes.len(), 1); + Statement::codegen(&json_nodes[0], context); } } diff --git a/src/cst/tags.rs b/src/cst/tags.rs index 8ea41af..be0a2b8 100644 --- a/src/cst/tags.rs +++ b/src/cst/tags.rs @@ -5,6 +5,7 @@ impl Tag { pub const MODULE_DECLARATION: &'static str = "kModuleDeclaration"; pub const MODULE_HEADER: &'static str = "kModuleHeader"; pub const MODULE_ITEM_LIST: &'static str = "kModuleItemList"; + pub const MODULE_PORT_DECLARATION: &'static str = "kModulePortDeclaration"; pub const PORT_IDENTIFIER_LIST: &'static str = "kPortIdentifierList"; pub const PORT_IDENTIFIER: &'static str = "kPortIdentifier"; @@ -16,19 +17,26 @@ impl Tag { pub const PACKED_DIMENSIONS: &'static str = "kPackedDimensions"; pub const DECLARATION_DIMENSIONS: &'static str = "kDeclarationDimensions"; pub const DIMENSION_RANGE: &'static str = "kDimensionRange"; + pub const SYMBOL_IDENTIFIER: &'static str = "SymbolIdentifier"; pub const EXPRESSION: &'static str = "kExpression"; pub const NUMBER: &'static str = "kNumber"; + pub const DEC_NUMBER: &'static str = "TK_DecNumber"; pub const ALWAYS_STATEMENT: &'static str = "kAlwaysStatement"; + pub const ALWAYS: &'static str = "always"; + pub const ALWAYS_COMB: &'static str = "always_comb"; pub const PROCEDURAL_TIMING_CONTROL_STATEMENT: &'static str = "kProceduralTimingControlStatement"; pub const EVENT_CONTROL: &'static str = "kEventControl"; pub const PAREN_GROUP: &'static str = "kParenGroup"; pub const EVENT_EXPRESSION_LIST: &'static str = "kEventExpressionList"; + pub const SEQ_BLOCK: &'static str = "kSeqBlock"; pub const BLOCK_ITEM_STATEMENT_LIST: &'static str = "kBlockItemStatementList"; + pub const NONBLOCKING_ASSIGNMENT_STATEMENT: &'static str = "kNonblockingAssignmentStatement"; + pub const CONDITIONAL_STATEMENT: &'static str = "kConditionalStatement"; pub const IF_CLAUSE: &'static str = "kIfClause"; pub const IF_HEADER: &'static str = "kIfHeader"; @@ -36,14 +44,14 @@ impl Tag { pub const ELSE_CLAUSE: &'static str = "kElseClause"; pub const ELSE_BODY: &'static str = "kElseBody"; - pub const NONBLOCKING_ASSIGNMENT_STATEMENT: &'static str = "kNonblockingAssignmentStatement"; pub const CASE_STATEMENT: &'static str = "kCaseStatement"; - pub const SYMBOL_IDENTIFIER: &'static str = "SymbolIdentifier"; - pub const DEC_NUMBER: &'static str = "TK_DecNumber"; + /* + pub const DATA_DECLARATION: &'static str = "kDataDeclaration"; + pub const NET_DECLARATION: &'static str = "kNetDeclaration"; + pub const CONTINUOUS_ASSIGNMENT_STATEMENT: &'static str = "kContinuousAssignmentStatement"; + */ pub const INPUT: &'static str = "input"; pub const OUTPUT: &'static str = "output"; - pub const ALWAYS: &'static str = "always"; - pub const ALWAYS_COMB: &'static str = "always_comb"; }