Skip to content

Commit ac20822

Browse files
committed
model X end Y; now reports a parse error! git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@2604 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent d5ad55d commit ac20822

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

modelica_parser/src/modelica_parser.g

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,16 +132,36 @@ class_type :
132132
;
133133

134134
class_specifier:
135-
IDENT class_specifier2
136-
| EXTENDS! IDENT (class_modification)? string_comment composition
137-
END! IDENT!
135+
i:IDENT class_specifier2[#i]
136+
| EXTENDS! i1:IDENT (class_modification)? string_comment composition
137+
END! i2:IDENT!
138138
{
139+
// check if the identifiers at the start and end are the same!
140+
if (i1->getText() != i2->getText())
141+
{
142+
throw
143+
ANTLR_USE_NAMESPACE(antlr)
144+
RecognitionException(
145+
"The identifier at start and end are different",
146+
modelicafilename, i2->getLine(), i2->getColumn());
147+
}
139148
#class_specifier = #([CLASS_EXTENDS,"CLASS_EXTENDS"],#class_specifier);
140149
}
141150
;
142151

143-
class_specifier2 :
144-
( string_comment composition END! IDENT!
152+
class_specifier2 [RefMyAST i1]:
153+
( string_comment composition END! i2:IDENT!
154+
{
155+
// check if the identifiers at the start and end are the same!
156+
if (RefMyAST(i1)->getText() != RefMyAST(#i2)->getText())
157+
{
158+
throw
159+
ANTLR_USE_NAMESPACE(antlr)
160+
RecognitionException(
161+
"The identifier at start and end are different",
162+
modelicafilename, i2->getLine(), i2->getColumn());
163+
}
164+
}
145165
| EQUALS^ base_prefix type_specifier ( class_modification )? comment
146166
| EQUALS^ enumeration
147167
| EQUALS^ pder

0 commit comments

Comments
 (0)