Skip to content

Commit 78ab97d

Browse files
author
Peter Aronsson
committed
Added transformation of . to _ in identifiers
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1443 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent c702460 commit 78ab97d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

flat_modelica_parser/src/flat_modelica_lexer.g

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
header {
2+
#include <string>
3+
#include <iostream>
4+
std::string & replaceAll(std::string & str, const char *src, const char* dst)
5+
{
6+
size_t pos;
7+
while((pos = str.find(".")) < str.size()-1) {
8+
str.replace(pos,1,"_");
9+
}
10+
return str;
11+
}
212

313
}
414

@@ -155,7 +165,14 @@ SL_COMMENT :
155165
;
156166

157167
IDENT options { testLiterals = true; paraphrase = "an identifier";} :
158-
NONDIGIT (NONDIGIT | DIGIT | DOT)*
168+
NONDIGIT (NONDIGIT | DIGIT | DOT )*
169+
{
170+
std::string tmp=$getText;
171+
$setText(replaceAll(tmp,
172+
".",
173+
"_"));
174+
}
175+
159176
;
160177

161178
TYVARIDENT options { testLiterals = true; paraphrase = "a type identifier";} :

0 commit comments

Comments
 (0)