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 : {
618
618
619
619
unit : " (" { scanner.scan_unit (); } " )"
620
620
{
621
- // @todo Empty units should be handled in semantic analysis
622
621
auto unit = scanner.get_unit ();
623
622
auto text = unit->eval ();
624
623
$$ = new ast::Unit (unit);
Original file line number Diff line number Diff line change 2
2
#include " ast/function_block.hpp"
3
3
#include " ast/procedure_block.hpp"
4
4
#include " ast/program.hpp"
5
+ #include " ast/string.hpp"
5
6
#include " ast/suffix.hpp"
6
7
#include " ast/table_statement.hpp"
8
+ #include " ast/unit.hpp"
7
9
#include " utils/logger.hpp"
8
10
#include " visitors/visitor_utils.hpp"
9
11
@@ -66,5 +68,14 @@ void SemanticAnalysisVisitor::visit_destructor_block(const ast::DestructorBlock&
66
68
// / -->
67
69
}
68
70
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
+
69
80
} // namespace visitor
70
81
} // namespace nmodl
Original file line number Diff line number Diff line change 26
26
* 1. Check that a function or a procedure containing a TABLE statement contains only one argument
27
27
* (mandatory in mod2c).
28
28
* 2. Check that destructor blocks are only inside mod file that are point_process
29
+ * 3. Check that unit always have a name
29
30
*/
30
31
#include " ast/ast.hpp"
31
32
#include " visitors/ast_visitor.hpp"
@@ -56,6 +57,9 @@ class SemanticAnalysisVisitor: public ConstAstVisitor {
56
57
// / Visit destructor and check that the file is of type POINT_PROCESS or ARTIFICIAL_CELL
57
58
void visit_destructor_block (const ast::DestructorBlock& node) override ;
58
59
60
+ // / Visit an unit and check that name is not empty
61
+ void visit_unit (const ast::Unit& node) override ;
62
+
59
63
public:
60
64
SemanticAnalysisVisitor () = default ;
61
65
You can’t perform that action at this time.
0 commit comments