Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit daab8bb

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Allow multiple class annotations in diff algorithm
Fixes ticket:4153
1 parent b0c9b43 commit daab8bb

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Compiler/Parsers/SimpleModelicaParser.mo

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,16 @@ algorithm
351351
(tokens, tree) := scan(tokens, tree, TokenId.SEMICOLON);
352352
end if;
353353

354-
(tokens, tree, b) := LA1(tokens, tree, First._annotation);
355-
if b then
356-
(tokens, tree) := _annotation(tokens, tree);
357-
(tokens, tree) := scan(tokens, tree, TokenId.SEMICOLON);
358-
end if;
354+
b := true;
355+
while b loop
356+
// OMEdit can sometimes insert multiple annotation-sections...
357+
(tokens, tree, b) := LA1(tokens, tree, First._annotation);
358+
if b then
359+
(tokens, tree) := _annotation(tokens, tree);
360+
(tokens, tree) := scan(tokens, tree, TokenId.SEMICOLON);
361+
end if;
362+
end while;
363+
359364
outTree := makeNodePrependTree(listReverse(tree), inTree);
360365
end composition;
361366

@@ -2744,7 +2749,7 @@ protected
27442749
SourceInfo info;
27452750
algorithm
27462751
info := topTokenSourceInfo(tokens);
2747-
res := ("Failed to scan top of input: " + topTokenStr(tokens) + "\n Expected one of: " + (if listEmpty(expected) then "<EOF>" else stringDelimitList(list(tokenIdStr(id) for id in expected), ", ")) + "\n")::{};
2752+
res := ("Failed to scan top of input: " + (if debug then debugTokenStr(tokens) else topTokenStr(tokens)) + "\n Expected one of: " + (if listEmpty(expected) then "<EOF>" else stringDelimitList(list(tokenIdStr(id) for id in expected), ", ")) + "\n")::{};
27482753
res := (" Current parse tree is:\n" + parseTreeStr(listReverse(tree)) + "\n The parser stack is:\n")::res;
27492754
StackOverflow.setStacktraceMessages(0, 100);
27502755
for s in StackOverflow.readableStacktraceMessages() loop
@@ -2865,6 +2870,13 @@ algorithm
28652870
str := (match tokens case (t as LexerModelicaDiff.TOKEN(id=id))::_ then String(id)+" ("+tokenContent(t)+")"; else "EOF"; end match);
28662871
end topTokenStr;
28672872

2873+
function debugTokenStr
2874+
input list<Token> tokens;
2875+
output String str;
2876+
algorithm
2877+
str := stringDelimitList(list(String(t.id)+" ("+tokenContent(t)+")" for t in tokens), "\n");
2878+
end debugTokenStr;
2879+
28682880
function topTokenSourceInfo
28692881
input list<Token> tokens;
28702882
output SourceInfo info;

0 commit comments

Comments
 (0)