Skip to content

Commit 8da52ca

Browse files
committed
Fix for class prefix walking, add node enum.
Signed-off-by: James Goppert <james.goppert@gmail.com>
1 parent 580caf4 commit 8da52ca

File tree

5 files changed

+86
-2
lines changed

5 files changed

+86
-2
lines changed

Cargo.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "rumoca_parser"
33
authors = ["James Goppert", "Benjamin Perseghetti"]
44
description = "A Modelica parser leveraging LALRPOP"
5-
version = "0.10.0"
5+
version = "0.10.1"
66
edition = "2021"
77
license = "Apache-2.0"
88

src/s1_parser/ast.rs

+82
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,88 @@ derive_alias! {
44
#[derive(CommonTraits!)] = #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)];
55
}
66

7+
#[derive(CommonTraits!, Default)]
8+
pub enum Node {
9+
#[default]
10+
Empty,
11+
StoredDefinition(StoredDefinition),
12+
ClassDefinition(ClassDefinition),
13+
ClassSpecifier(ClassSpecifier),
14+
CompositionPart(CompositionPart),
15+
Element(Element),
16+
ComponentDeclaration(ComponentDeclaration),
17+
ClassPrefixes(ClassPrefixes),
18+
ComponentClause(ComponentClause),
19+
ComponentClause1(ComponentClause1),
20+
Declaration(Declaration),
21+
TypeSpecifier(TypeSpecifier),
22+
Equation(Equation),
23+
IfEquationBlock(IfEquationBlock),
24+
Statement(Statement),
25+
IfStatementBlock(IfStatementBlock),
26+
Expression(Expression),
27+
IfExpressionBlock(IfExpressionBlock),
28+
ComponentReference(ComponentReference),
29+
RefPart(RefPart),
30+
Subscript(Subscript),
31+
Argument(Argument),
32+
Modification(Modification),
33+
ModExpr(ModExpr),
34+
Description(Description),
35+
TypePrefix(TypePrefix),
36+
ForIndex(ForIndex),
37+
Span(Span),
38+
ElementFlags(ElementFlags),
39+
Causality(Causality),
40+
Variability(Variability),
41+
Visibility(Visibility),
42+
Connection(Connection),
43+
UnaryOp(UnaryOp),
44+
BinaryOp(BinaryOp),
45+
ClassType(ClassType),
46+
}
47+
48+
#[derive(Default, Clone, Debug, PartialEq, Eq, Hash)]
49+
pub enum NodeRef<'a> {
50+
#[default]
51+
Empty,
52+
StoredDefinition(& 'a StoredDefinition),
53+
ClassDefinition(& 'a ClassDefinition),
54+
ClassSpecifier(& 'a ClassSpecifier),
55+
CompositionPart(& 'a CompositionPart),
56+
Element(& 'a Element),
57+
ComponentDeclaration(& 'a ComponentDeclaration),
58+
ClassPrefixes(& 'a ClassPrefixes),
59+
ComponentClause(& 'a ComponentClause),
60+
ComponentClause1(& 'a ComponentClause1),
61+
Declaration(& 'a Declaration),
62+
TypeSpecifier(& 'a TypeSpecifier),
63+
Equation(& 'a Equation),
64+
IfEquationBlock(& 'a IfEquationBlock),
65+
Statement(& 'a Statement),
66+
IfStatementBlock(& 'a IfStatementBlock),
67+
Expression(& 'a Expression),
68+
IfExpressionBlock(& 'a IfExpressionBlock),
69+
ComponentReference(& 'a ComponentReference),
70+
RefPart(& 'a RefPart),
71+
Subscript(& 'a Subscript),
72+
Argument(& 'a Argument),
73+
Modification(& 'a Modification),
74+
ModExpr(& 'a ModExpr),
75+
Description(& 'a Description),
76+
TypePrefix(& 'a TypePrefix),
77+
ForIndex(& 'a ForIndex),
78+
Span(& 'a Span),
79+
ElementFlags(& 'a ElementFlags),
80+
Causality(& 'a Causality),
81+
Variability(& 'a Variability),
82+
Visibility(& 'a Visibility),
83+
Connection(& 'a Connection),
84+
UnaryOp(& 'a UnaryOp),
85+
BinaryOp(& 'a BinaryOp),
86+
ClassType(& 'a ClassType),
87+
}
88+
789
// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
890
// File Level Nodes
991

src/s2_analysis/visitable.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl<'a> Visitable<'a> for ast::ClassDefinition {
2828
fn accept<V: Visitor<'a> + ?Sized>(&'a self, visitor: &mut V) {
2929
visitor.enter_any();
3030
visitor.enter_class_definition(self);
31+
self.prefixes.accept(visitor);
3132
self.specifier.accept(visitor);
3233
visitor.exit_class_definition(self);
3334
visitor.exit_any();

src/s2_analysis/visitable_mut.rs

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ impl VisitableMut for ast::ClassDefinition {
2828
fn accept_mut<V: VisitorMut + ?Sized>(&mut self, visitor: &mut V) {
2929
visitor.enter_any();
3030
visitor.enter_class_definition_mut(self);
31+
self.prefixes.accept_mut(visitor);
3132
self.specifier.accept_mut(visitor);
3233
visitor.exit_class_definition_mut(self);
3334
visitor.exit_any();

0 commit comments

Comments
 (0)