This repository was archived by the owner on Mar 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -618,7 +618,6 @@ units : {
618618
619619unit : " (" { scanner.scan_unit (); } " )"
620620 {
621- // @todo Empty units should be handled in semantic analysis
622621 auto unit = scanner.get_unit ();
623622 auto text = unit->eval ();
624623 $$ = new ast::Unit (unit);
Original file line number Diff line number Diff line change 22#include " ast/function_block.hpp"
33#include " ast/procedure_block.hpp"
44#include " ast/program.hpp"
5+ #include " ast/string.hpp"
56#include " ast/suffix.hpp"
67#include " ast/table_statement.hpp"
8+ #include " ast/unit.hpp"
79#include " utils/logger.hpp"
810#include " visitors/visitor_utils.hpp"
911
@@ -66,5 +68,14 @@ void SemanticAnalysisVisitor::visit_destructor_block(const ast::DestructorBlock&
6668 // / -->
6769}
6870
71+ void SemanticAnalysisVisitor::visit_unit (const ast::Unit& node) {
72+ // / <-- This code is for check 3
73+ if (node.get_name ()->get_value ().empty ()) {
74+ logger->warn (" SemanticAnalysisVisitor:: An unit cannot be created without name." );
75+ check_fail = true ;
76+ }
77+ // / -->
78+ }
79+
6980} // namespace visitor
7081} // namespace nmodl
Original file line number Diff line number Diff line change 2626 * 1. Check that a function or a procedure containing a TABLE statement contains only one argument
2727 * (mandatory in mod2c).
2828 * 2. Check that destructor blocks are only inside mod file that are point_process
29+ * 3. Check that unit always have a name
2930 */
3031#include " ast/ast.hpp"
3132#include " visitors/ast_visitor.hpp"
@@ -56,6 +57,9 @@ class SemanticAnalysisVisitor: public ConstAstVisitor {
5657 // / Visit destructor and check that the file is of type POINT_PROCESS or ARTIFICIAL_CELL
5758 void visit_destructor_block (const ast::DestructorBlock& node) override ;
5859
60+ // / Visit an unit and check that name is not empty
61+ void visit_unit (const ast::Unit& node) override ;
62+
5963 public:
6064 SemanticAnalysisVisitor () = default ;
6165
You can’t perform that action at this time.
0 commit comments