Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 51.3% 140 / 0 / 273
Functions: -% 0 / 1 / 1
Branches: 30.1% 41 / 0 / 136

OMCompiler/Compiler/Lexers/LexerModelicaDiff.mo
Line Branch Exec Source
1 encapsulated package LexerModelicaDiff "Automatically generated lexer based on flex, generated OMCCp v0.11.0 OpenModelica lexer and parser generator (2015)"
2 /*
3 Template for Lexer Code
4 replace keywords:
5 %LexerCode
6 %time
7 %Token
8 %Lexer
9 %LexTable
10 %constant
11 %nameSpan
12 %functions
13 %caseAction
14 */
15
16 import System;
17
18 constant Boolean debug = false;
19
20 replaceable package LexTable
21 constant Integer yy_limit;
22 constant Integer yy_finish;
23 constant array<Integer> yy_acclist;
24 constant array<Integer> yy_accept;
25 constant array<Integer> yy_ec;
26 constant array<Integer> yy_meta;
27 constant array<Integer> yy_base;
28 constant array<Integer> yy_def;
29 constant array<Integer> yy_nxt;
30 constant array<Integer> yy_chk;
31 end LexTable;
32
33 function scan "Scan starts the lexical analysis, load the tables and consume the program to output the tokens"
34 input String fileName "input source code file";
35 output list<Token> tokens "return list of tokens";
36 output list<Token> errorTokens;
37 protected
38 String contents;
39 algorithm
40 ✗ contents := System.readFile(fileName);
41 ✗ (tokens, errorTokens) := lex(fileName,contents);
42 end scan;
43
44 function scanString "Scan starts the lexical analysis, load the tables and consume the program to output the tokens"
45 input String fileSource "input source code file";
46 input String fileName = "<StringSource>";
47 output list<Token> tokens "return list of tokens";
48 output list<Token> errorTokens;
49 algorithm
50 184 (tokens, errorTokens) := lex(fileName,fileSource);
51 end scanString;
52
53
54 import DiffAlgorithm;
55 protected
56 import Error;
57 import StringUtil;
58 public
59 function action
60 input Integer act;
61 input Integer startSt;
62 input Integer mm_currSt,mm_pos,mm_sPos,mm_ePos,mm_linenr,lineNrStart;
63 input Integer buffer;
64 input String fileNm;
65 input String fileContents;
66 input list<Token> inErrorTokens;
67 output Token token;
68 output Integer mm_startSt;
69 output Integer bufferRet;
70 output list<Token> errorTokens=inErrorTokens;
71 protected
72 algorithm
73 mm_startSt := startSt;
74 // nameSpan := 255;
75 bufferRet := 0;
76 token := match act
77 local
78 Token tok;
79 case 1 // #line 36 "lexerModelicaDiff.l"
80 algorithm
81 2073 tok := TOKEN(fileNm,TokenId.WHITESPACE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
82 then tok;
83 case 2 // #line 37 "lexerModelicaDiff.l"
84 algorithm
85 836 tok := TOKEN(fileNm,TokenId.NEWLINE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
86 then tok;
87 case 3 // #line 38 "lexerModelicaDiff.l"
88 algorithm
89 52 tok := TOKEN(fileNm,TokenId.UNSIGNED_REAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
90 then tok;
91 case 4 // #line 39 "lexerModelicaDiff.l"
92 algorithm
93 ✗ tok := TOKEN(fileNm,TokenId.UNSIGNED_REAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
94 then tok;
95 case 5 // #line 40 "lexerModelicaDiff.l"
96 algorithm
97 ✗ tok := TOKEN(fileNm,TokenId.UNSIGNED_REAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
98 then tok;
99 case 6 // #line 41 "lexerModelicaDiff.l"
100 algorithm
101 56 tok := TOKEN(fileNm,TokenId.ALGORITHM,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
102 then tok;
103 case 7 // #line 42 "lexerModelicaDiff.l"
104 algorithm
105 ✗ tok := TOKEN(fileNm,TokenId.AND,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
106 then tok;
107 case 8 // #line 43 "lexerModelicaDiff.l"
108 algorithm
109 15 tok := TOKEN(fileNm,TokenId.ANNOTATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
110 then tok;
111 case 9 // #line 44 "lexerModelicaDiff.l"
112 algorithm
113 12 tok := TOKEN(fileNm,TokenId.BLOCK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
114 then tok;
115 case 10 // #line 45 "lexerModelicaDiff.l"
116 algorithm
117 ✗ tok := TOKEN(fileNm,TokenId.CLASS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
118 then tok;
119 case 11 // #line 46 "lexerModelicaDiff.l"
120 algorithm
121 4 tok := TOKEN(fileNm,TokenId.CONNECT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
122 then tok;
123 case 12 // #line 47 "lexerModelicaDiff.l"
124 algorithm
125 ✗ tok := TOKEN(fileNm,TokenId.CONNECTOR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
126 then tok;
127 case 13 // #line 48 "lexerModelicaDiff.l"
128 algorithm
129 4 tok := TOKEN(fileNm,TokenId.CONSTANT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
130 then tok;
131 case 14 // #line 49 "lexerModelicaDiff.l"
132 algorithm
133 ✗ tok := TOKEN(fileNm,TokenId.DISCRETE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
134 then tok;
135 case 15 // #line 50 "lexerModelicaDiff.l"
136 algorithm
137 ✗ tok := TOKEN(fileNm,TokenId.DER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
138 then tok;
139 case 16 // #line 51 "lexerModelicaDiff.l"
140 algorithm
141 ✗ tok := TOKEN(fileNm,TokenId.DEFINEUNIT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
142 then tok;
143 case 17 // #line 52 "lexerModelicaDiff.l"
144 algorithm
145 ✗ tok := TOKEN(fileNm,TokenId.EACH,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
146 then tok;
147 case 18 // #line 53 "lexerModelicaDiff.l"
148 algorithm
149 56 tok := TOKEN(fileNm,TokenId.ELSE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
150 then tok;
151 case 19 // #line 54 "lexerModelicaDiff.l"
152 algorithm
153 ✗ tok := TOKEN(fileNm,TokenId.ELSEIF,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
154 then tok;
155 case 20 // #line 55 "lexerModelicaDiff.l"
156 algorithm
157 ✗ tok := TOKEN(fileNm,TokenId.ELSEWHEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
158 then tok;
159 case 21 // #line 56 "lexerModelicaDiff.l"
160 algorithm
161 242 tok := TOKEN(fileNm,TokenId.END,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
162 then tok;
163 case 22 // #line 57 "lexerModelicaDiff.l"
164 algorithm
165 ✗ tok := TOKEN(fileNm,TokenId.ENUMERATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
166 then tok;
167 case 23 // #line 58 "lexerModelicaDiff.l"
168 algorithm
169 12 tok := TOKEN(fileNm,TokenId.EQUATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
170 then tok;
171 case 24 // #line 59 "lexerModelicaDiff.l"
172 algorithm
173 ✗ tok := TOKEN(fileNm,TokenId.ENCAPSULATED,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
174 then tok;
175 case 25 // #line 60 "lexerModelicaDiff.l"
176 algorithm
177 ✗ tok := TOKEN(fileNm,TokenId.EXPANDABLE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
178 then tok;
179 case 26 // #line 61 "lexerModelicaDiff.l"
180 algorithm
181 4 tok := TOKEN(fileNm,TokenId.EXTENDS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
182 then tok;
183 case 27 // #line 62 "lexerModelicaDiff.l"
184 algorithm
185 ✗ tok := TOKEN(fileNm,TokenId.CONSTRAINEDBY,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
186 then tok;
187 case 28 // #line 63 "lexerModelicaDiff.l"
188 algorithm
189 ✗ tok := TOKEN(fileNm,TokenId.EXTERNAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
190 then tok;
191 case 29 // #line 64 "lexerModelicaDiff.l"
192 algorithm
193 4 tok := TOKEN(fileNm,TokenId.FALSE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
194 then tok;
195 case 30 // #line 65 "lexerModelicaDiff.l"
196 algorithm
197 16 tok := TOKEN(fileNm,TokenId.FINAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
198 then tok;
199 case 31 // #line 66 "lexerModelicaDiff.l"
200 algorithm
201 ✗ tok := TOKEN(fileNm,TokenId.FLOW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
202 then tok;
203 case 32 // #line 67 "lexerModelicaDiff.l"
204 algorithm
205 ✗ tok := TOKEN(fileNm,TokenId.FOR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
206 then tok;
207 case 33 // #line 68 "lexerModelicaDiff.l"
208 algorithm
209 4 tok := TOKEN(fileNm,TokenId.FUNCTION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
210 then tok;
211 case 34 // #line 69 "lexerModelicaDiff.l"
212 algorithm
213 108 tok := TOKEN(fileNm,TokenId.IF,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
214 then tok;
215 case 35 // #line 70 "lexerModelicaDiff.l"
216 algorithm
217 ✗ tok := TOKEN(fileNm,TokenId.IMPORT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
218 then tok;
219 case 36 // #line 71 "lexerModelicaDiff.l"
220 algorithm
221 ✗ tok := TOKEN(fileNm,TokenId.IN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
222 then tok;
223 case 37 // #line 72 "lexerModelicaDiff.l"
224 algorithm
225 ✗ tok := TOKEN(fileNm,TokenId.INITIAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
226 then tok;
227 case 38 // #line 73 "lexerModelicaDiff.l"
228 algorithm
229 ✗ tok := TOKEN(fileNm,TokenId.INNER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
230 then tok;
231 case 39 // #line 74 "lexerModelicaDiff.l"
232 algorithm
233 ✗ tok := TOKEN(fileNm,TokenId.INPUT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
234 then tok;
235 case 40 // #line 75 "lexerModelicaDiff.l"
236 algorithm
237 ✗ tok := TOKEN(fileNm,TokenId.LOOP,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
238 then tok;
239 case 41 // #line 76 "lexerModelicaDiff.l"
240 algorithm
241 165 tok := TOKEN(fileNm,TokenId.MODEL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
242 then tok;
243 case 42 // #line 77 "lexerModelicaDiff.l"
244 algorithm
245 ✗ tok := TOKEN(fileNm,TokenId.NOT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
246 then tok;
247 case 43 // #line 78 "lexerModelicaDiff.l"
248 algorithm
249 ✗ tok := TOKEN(fileNm,TokenId.OUTER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
250 then tok;
251 case 44 // #line 79 "lexerModelicaDiff.l"
252 algorithm
253 ✗ tok := TOKEN(fileNm,TokenId.OPERATOR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
254 then tok;
255 case 45 // #line 80 "lexerModelicaDiff.l"
256 algorithm
257 ✗ tok := TOKEN(fileNm,TokenId.OVERLOAD,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
258 then tok;
259 case 46 // #line 81 "lexerModelicaDiff.l"
260 algorithm
261 4 tok := TOKEN(fileNm,TokenId.OR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
262 then tok;
263 case 47 // #line 82 "lexerModelicaDiff.l"
264 algorithm
265 ✗ tok := TOKEN(fileNm,TokenId.OUTPUT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
266 then tok;
267 case 48 // #line 83 "lexerModelicaDiff.l"
268 algorithm
269 13 tok := TOKEN(fileNm,TokenId.PACKAGE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
270 then tok;
271 case 49 // #line 84 "lexerModelicaDiff.l"
272 algorithm
273 ✗ tok := TOKEN(fileNm,TokenId.PARAMETER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
274 then tok;
275 case 50 // #line 85 "lexerModelicaDiff.l"
276 algorithm
277 8 tok := TOKEN(fileNm,TokenId.PARTIAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
278 then tok;
279 case 51 // #line 86 "lexerModelicaDiff.l"
280 algorithm
281 ✗ tok := TOKEN(fileNm,TokenId.PROTECTED,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
282 then tok;
283 case 52 // #line 87 "lexerModelicaDiff.l"
284 algorithm
285 ✗ tok := TOKEN(fileNm,TokenId.PUBLIC,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
286 then tok;
287 case 53 // #line 88 "lexerModelicaDiff.l"
288 algorithm
289 ✗ tok := TOKEN(fileNm,TokenId.RECORD,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
290 then tok;
291 case 54 // #line 89 "lexerModelicaDiff.l"
292 algorithm
293 4 tok := TOKEN(fileNm,TokenId.REDECLARE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
294 then tok;
295 case 55 // #line 90 "lexerModelicaDiff.l"
296 algorithm
297 ✗ tok := TOKEN(fileNm,TokenId.REPLACEABLE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
298 then tok;
299 case 56 // #line 91 "lexerModelicaDiff.l"
300 algorithm
301 56 tok := TOKEN(fileNm,TokenId.THEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
302 then tok;
303 case 57 // #line 92 "lexerModelicaDiff.l"
304 algorithm
305 7 tok := TOKEN(fileNm,TokenId.TRUE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
306 then tok;
307 case 58 // #line 93 "lexerModelicaDiff.l"
308 algorithm
309 ✗ tok := TOKEN(fileNm,TokenId.TYPE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
310 then tok;
311 case 59 // #line 94 "lexerModelicaDiff.l"
312 algorithm
313 ✗ tok := TOKEN(fileNm,TokenId.WHEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
314 then tok;
315 case 60 // #line 95 "lexerModelicaDiff.l"
316 algorithm
317 ✗ tok := TOKEN(fileNm,TokenId.WHILE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
318 then tok;
319 case 61 // #line 96 "lexerModelicaDiff.l"
320 algorithm
321 10 tok := TOKEN(fileNm,TokenId.WITHIN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
322 then tok;
323 case 62 // #line 97 "lexerModelicaDiff.l"
324 algorithm
325 ✗ tok := TOKEN(fileNm,TokenId.RETURN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
326 then tok;
327 case 63 // #line 98 "lexerModelicaDiff.l"
328 algorithm
329 ✗ tok := TOKEN(fileNm,TokenId.BREAK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
330 then tok;
331 case 64 // #line 100 "lexerModelicaDiff.l"
332 algorithm
333 117 tok := TOKEN(fileNm,TokenId.LPAR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
334 then tok;
335 case 65 // #line 101 "lexerModelicaDiff.l"
336 algorithm
337 117 tok := TOKEN(fileNm,TokenId.RPAR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
338 then tok;
339 case 66 // #line 102 "lexerModelicaDiff.l"
340 algorithm
341 4 tok := TOKEN(fileNm,TokenId.LBRACK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
342 then tok;
343 case 67 // #line 103 "lexerModelicaDiff.l"
344 algorithm
345 4 tok := TOKEN(fileNm,TokenId.RBRACK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
346 then tok;
347 case 68 // #line 104 "lexerModelicaDiff.l"
348 algorithm
349 112 tok := TOKEN(fileNm,TokenId.LBRACE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
350 then tok;
351 case 69 // #line 105 "lexerModelicaDiff.l"
352 algorithm
353 112 tok := TOKEN(fileNm,TokenId.RBRACE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
354 then tok;
355 case 70 // #line 106 "lexerModelicaDiff.l"
356 algorithm
357 12 tok := TOKEN(fileNm,TokenId.EQEQ,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
358 then tok;
359 case 71 // #line 107 "lexerModelicaDiff.l"
360 algorithm
361 127 tok := TOKEN(fileNm,TokenId.EQUALS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
362 then tok;
363 case 72 // #line 108 "lexerModelicaDiff.l"
364 algorithm
365 208 tok := TOKEN(fileNm,TokenId.COMMA,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
366 then tok;
367 case 73 // #line 109 "lexerModelicaDiff.l"
368 algorithm
369 100 tok := TOKEN(fileNm,TokenId.ASSIGN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
370 then tok;
371 case 74 // #line 110 "lexerModelicaDiff.l"
372 algorithm
373 ✗ tok := TOKEN(fileNm,TokenId.COLONCOLON,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
374 then tok;
375 case 75 // #line 111 "lexerModelicaDiff.l"
376 algorithm
377 ✗ tok := TOKEN(fileNm,TokenId.COLON,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
378 then tok;
379 case 76 // #line 112 "lexerModelicaDiff.l"
380 algorithm
381 523 tok := TOKEN(fileNm,TokenId.SEMICOLON,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
382 then tok;
383 case 77 // #line 114 "lexerModelicaDiff.l"
384 algorithm
385 ✗ tok := TOKEN(fileNm,TokenId.PURE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
386 then tok;
387 case 78 // #line 115 "lexerModelicaDiff.l"
388 algorithm
389 ✗ tok := TOKEN(fileNm,TokenId.IMPURE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
390 then tok;
391 case 79 // #line 116 "lexerModelicaDiff.l"
392 algorithm
393 ✗ tok := TOKEN(fileNm,TokenId.OPTIMIZATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
394 then tok;
395 case 80 // #line 118 "lexerModelicaDiff.l"
396 algorithm
397 ✗ tok := TOKEN(fileNm,TokenId.PLUS_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
398 then tok;
399 case 81 // #line 119 "lexerModelicaDiff.l"
400 algorithm
401 ✗ tok := TOKEN(fileNm,TokenId.MINUS_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
402 then tok;
403 case 82 // #line 120 "lexerModelicaDiff.l"
404 algorithm
405 ✗ tok := TOKEN(fileNm,TokenId.STAR_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
406 then tok;
407 case 83 // #line 121 "lexerModelicaDiff.l"
408 algorithm
409 ✗ tok := TOKEN(fileNm,TokenId.SLASH_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
410 then tok;
411 case 84 // #line 122 "lexerModelicaDiff.l"
412 algorithm
413 ✗ tok := TOKEN(fileNm,TokenId.POWER_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
414 then tok;
415 case 85 // #line 124 "lexerModelicaDiff.l"
416 algorithm
417 4 tok := TOKEN(fileNm,TokenId.STAR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
418 then tok;
419 case 86 // #line 125 "lexerModelicaDiff.l"
420 algorithm
421 44 tok := TOKEN(fileNm,TokenId.MINUS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
422 then tok;
423 case 87 // #line 126 "lexerModelicaDiff.l"
424 algorithm
425 12 tok := TOKEN(fileNm,TokenId.PLUS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
426 then tok;
427 case 88 // #line 127 "lexerModelicaDiff.l"
428 algorithm
429 ✗ tok := TOKEN(fileNm,TokenId.LESSEQ,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
430 then tok;
431 case 89 // #line 128 "lexerModelicaDiff.l"
432 algorithm
433 ✗ tok := TOKEN(fileNm,TokenId.LESSGT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
434 then tok;
435 case 90 // #line 129 "lexerModelicaDiff.l"
436 algorithm
437 ✗ tok := TOKEN(fileNm,TokenId.LESS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
438 then tok;
439 case 91 // #line 130 "lexerModelicaDiff.l"
440 algorithm
441 48 tok := TOKEN(fileNm,TokenId.GREATER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
442 then tok;
443 case 92 // #line 131 "lexerModelicaDiff.l"
444 algorithm
445 ✗ tok := TOKEN(fileNm,TokenId.GREATEREQ,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
446 then tok;
447 case 93 // #line 133 "lexerModelicaDiff.l"
448 algorithm
449 ✗ tok := TOKEN(fileNm,TokenId.POWER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
450 then tok;
451 case 94 // #line 134 "lexerModelicaDiff.l"
452 algorithm
453 20 tok := TOKEN(fileNm,TokenId.SLASH,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
454 then tok;
455 case 95 // #line 136 "lexerModelicaDiff.l"
456 algorithm
457 ✗ tok := TOKEN(fileNm,TokenId.SUBTYPEOF,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
458 then tok;
459 case 96 // #line 138 "lexerModelicaDiff.l"
460 algorithm
461 ✗ tok := TOKEN(fileNm,TokenId.STREAM,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
462 then tok;
463 case 97 // #line 140 "lexerModelicaDiff.l"
464 algorithm
465 191 tok := TOKEN(fileNm,TokenId.DOT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
466 then tok;
467 case 98 // #line 142 "lexerModelicaDiff.l"
468 algorithm
469 1337 tok := TOKEN(fileNm,TokenId.IDENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
470 then tok;
471 case 99 // #line 144 "lexerModelicaDiff.l"
472 algorithm
473 ✗ tok := TOKEN(fileNm,TokenId.IDENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
474 then tok;
475 case 100 // #line 146 "lexerModelicaDiff.l"
476 algorithm
477 308 tok := TOKEN(fileNm,TokenId.UNSIGNED_INTEGER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
478 then tok;
479 case 101 // #line 148 "lexerModelicaDiff.l"
480 algorithm
481 mm_startSt := 7;
482 bufferRet := buffer;
483 then noToken;
484 case 102 // #line 153 "lexerModelicaDiff.l"
485 algorithm
486 bufferRet := buffer;
487 then noToken;
488 case 103 // #line 154 "lexerModelicaDiff.l"
489 algorithm
490 bufferRet := buffer;
491 then noToken;
492 case 104 // #line 155 "lexerModelicaDiff.l"
493 algorithm
494 mm_startSt := 1;
495 32 tok := TOKEN(fileNm,TokenId.STRING,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
496 then tok;
497 case 105 // #line 156 "lexerModelicaDiff.l"
498 algorithm
499 bufferRet := buffer;
500 then noToken;
501 case 106 // #line 157 "lexerModelicaDiff.l"
502 algorithm
503 bufferRet := buffer;
504 then noToken;
505 case 107 // #line 160 "lexerModelicaDiff.l"
506 algorithm
507 mm_startSt := 3;
508 bufferRet := buffer;
509 then noToken;
510 case 108 // #line 165 "lexerModelicaDiff.l"
511 algorithm
512 mm_startSt := 1;
513 48 tok := TOKEN(fileNm,TokenId.BLOCK_COMMENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
514 then tok;
515 case 109 // #line 166 "lexerModelicaDiff.l"
516 algorithm
517 bufferRet := buffer;
518 then noToken;
519 case 110 // #line 167 "lexerModelicaDiff.l"
520 algorithm
521 bufferRet := buffer;
522 then noToken;
523 case 111 // #line 174 "lexerModelicaDiff.l"
524 algorithm
525 mm_startSt := 5;
526 bufferRet := buffer;
527 then noToken;
528 case 112 // #line 180 "lexerModelicaDiff.l"
529 algorithm
530 mm_startSt := 1;
531 32 tok := TOKEN(fileNm,TokenId.LINE_COMMENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
532 then tok;
533 case 113 // #line 181 "lexerModelicaDiff.l"
534 algorithm
535 bufferRet := buffer;
536 then noToken;
537 case 114 // #line 184 "lexerModelicaDiff.l"
538 algorithm
539 ✗ tok := TOKEN(fileNm,TokenId._NO_TOKEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
540 errorTokens := tok :: errorTokens;
541 then noToken;
542
543 else
544 algorithm
545 ✗ print("\nLexer unknown rule, action="+String(act)+"\n");
546 ✗ tok := TOKEN(fileNm,TokenId._NO_TOKEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
547 ✗ print(printToken(tok));
548 ✗ then fail();
549 end match;
550 end action;
551
552 type TokenId = enumeration(
553 _NO_TOKEN,
554 ALGORITHM,
555 AND,
556 ANNOTATION,
557 ASSIGN,
558 BLOCK,
559 BLOCK_COMMENT,
560 BREAK,
561 CLASS,
562 COLON,
563 COLONCOLON,
564 COMMA,
565 CONNECT,
566 CONNECTOR,
567 CONSTANT,
568 CONSTRAINEDBY,
569 DEFINEUNIT,
570 DER,
571 DISCRETE,
572 DOT,
573 EACH,
574 ELSE,
575 ELSEIF,
576 ELSEWHEN,
577 ENCAPSULATED,
578 END,
579 ENUMERATION,
580 EQEQ,
581 EQUALS,
582 EQUATION,
583 EXPANDABLE,
584 EXTENDS,
585 EXTERNAL,
586 FALSE,
587 FINAL,
588 FLOW,
589 FOR,
590 FUNCTION,
591 GREATER,
592 GREATEREQ,
593 IDENT,
594 IF,
595 IMPORT,
596 IMPURE,
597 IN,
598 INITIAL,
599 INNER,
600 INPUT,
601 LBRACE,
602 LBRACK,
603 LESS,
604 LESSEQ,
605 LESSGT,
606 LINE_COMMENT,
607 LOOP,
608 LPAR,
609 MINUS,
610 MINUS_EW,
611 MODEL,
612 MODELICA,
613 NEWLINE,
614 NOT,
615 OPERATOR,
616 OPTIMIZATION,
617 OR,
618 OUTER,
619 OUTPUT,
620 OVERLOAD,
621 PACKAGE,
622 PARAMETER,
623 PARTIAL,
624 PLUS,
625 PLUS_EW,
626 POWER,
627 POWER_EW,
628 PROTECTED,
629 PUBLIC,
630 PURE,
631 RBRACE,
632 RBRACK,
633 RECORD,
634 REDECLARE,
635 REPLACEABLE,
636 RETURN,
637 RPAR,
638 SEMICOLON,
639 SLASH,
640 SLASH_EW,
641 STAR,
642 STAR_EW,
643 STREAM,
644 STRING,
645 SUBTYPEOF,
646 THEN,
647 TRUE,
648 TYPE,
649 UNSIGNED_INTEGER,
650 UNSIGNED_REAL,
651 WHEN,
652 WHILE,
653 WHITESPACE,
654 WITHIN
655 );
656
657 uniontype Token
658 record TOKEN
659 String fileName;
660 TokenId id;
661 String fileContents;
662 Integer byteOffset,length;
663 Integer lineNumberStart;
664 Integer columnNumberStart;
665 Integer lineNumberEnd;
666 Integer columnNumberEnd;
667 end TOKEN;
668 end Token;
669
670 constant Token noToken = TOKEN("<NoFile>",TokenId._NO_TOKEN,"",0,0,0,0,0,0);
671
672 function printToken
673 input Token token;
674 output String strTk;
675 protected
676 TokenId id;
677 String contents;
678 Integer byteOffset,length;
679 algorithm
680 ✗ TOKEN(id=id, fileContents=contents, byteOffset=byteOffset, length=length) := token;
681 ✗ contents := if length>0 then substring(contents,byteOffset,byteOffset+length-1) else "";
682 ✗ strTk := "[TOKEN:" + String(id) + " '" + contents +"' (" + intString(token.lineNumberStart) + ":" + intString(token.columnNumberStart) + "-"+ intString(token.lineNumberEnd) + ":" + intString(token.columnNumberEnd) +")]";
683 end printToken;
684
685 function tokenContent
686 input Token token;
687 output String contents;
688 protected
689 Integer byteOffset,length;
690 algorithm
691 6386 TOKEN(fileContents=contents,byteOffset=byteOffset,length=length) := token;
692
1/2
✓ Branch 0 taken 6386 times.
✗ Branch 1 not taken.
6386 contents := if length>0 then substring(contents,byteOffset,byteOffset+length-1) else "";
693 end tokenContent;
694
695 function tokenContentEq
696 input Token token1, token2;
697 output Boolean b;
698 protected
699 String contents1,contents2;
700 Integer offset1,length1,offset2,length2;
701 algorithm
702 3843 TOKEN(fileContents=contents1,byteOffset=offset1,length=length1) := token1;
703 3843 TOKEN(fileContents=contents2,byteOffset=offset2,length=length2) := token2;
704 // We do not need to know in which order to sort. If lengths differ, the tokens differ
705
4/4
✓ Branch 0 taken 3432 times.
✓ Branch 1 taken 411 times.
✓ Branch 3 taken 360 times.
✓ Branch 4 taken 3072 times.
3843 b := if length1 <> length2 then false else (0 == System.strcmp_offset(contents1, offset1, length1, contents2, offset2, length2));
706 end tokenContentEq;
707
708 function tokenSourceInfo
709 input Token token;
710 output SourceInfo info;
711 algorithm
712 info := match t as token
713 ✗ case TOKEN() then SOURCEINFO(t.fileName, false, t.lineNumberStart, t.columnNumberStart, t.lineNumberEnd, t.columnNumberEnd, 0.0);
714 end match;
715 end tokenSourceInfo;
716
717 protected
718
719 function lex "Scan starts the lexical analysis, load the tables and consume the program to output the tokens"
720 input String fileName "input source code file";
721 input String contents;
722 output list<Token> tokens "return list of tokens";
723 output list<Token> errorTokens={};
724 protected
725 Integer startSt,i,cTok,currSt,pos,sPos,ePos,linenr,contentLen,numBacktrack,buffer,lineNrStart;
726 list<Integer> states;
727 import MetaModelica.Dangerous.listReverseInPlace;
728 import stringGet = MetaModelica.Dangerous.stringGetNoBoundsChecking;
729 algorithm
730 // load arrays
731
732 // Initialize the Env Variables
733 184 startSt := 1;
734 184 currSt := 1;
735 184 pos := 1;
736 184 sPos := 0;
737 184 ePos := 0;
738 184 linenr := 1;
739 184 lineNrStart := 1;
740 184 buffer := 0;
741
742 184 states := {};
743
744 if (debug==true) then
745 print("\nLexer analyzer LexerCode..." + fileName + "\n");
746 //printAny("\nLexer analyzer LexerCode..." + fileName + "\n");
747 end if;
748
749 tokens := {};
750 if (debug) then
751 print("\n TOTAL Chars:");
752 print(intString(stringLength(contents)));
753 end if;
754 184 contentLen := stringLength(contents);
755 i := 1;
756
2/2
✓ Branch 0 taken 25461 times.
✓ Branch 1 taken 184 times.
25645 while i <= contentLen loop
757 25461 cTok := stringGet(contents,i);
758 25461 (tokens,numBacktrack,startSt,currSt,pos,sPos,ePos,linenr,lineNrStart,buffer,states,errorTokens) := consume(cTok,tokens,contents,startSt,currSt,pos,sPos,ePos,linenr,lineNrStart,buffer,states,fileName,errorTokens);
759 25461 i := i - numBacktrack + 1;
760 end while;
761 184 tokens := listReverseInPlace(tokens);
762 184 errorTokens := listReverseInPlace(errorTokens);
763 end lex;
764
765 function consume
766 input Integer cp;
767 input list<Token> tokens;
768 input String fileContents;
769 input Integer startSt;
770 input Integer currSt,pos,sPos,ePos,linenr,inLineNrStart;
771 input Integer inBuffer;
772 input list<Integer> inStates;
773 input String fileName;
774 input list<Token> inErrorTokens;
775 output list<Token> resToken;
776 output Integer bkBuffer = 0;
777 output Integer mm_startSt;
778 output Integer mm_currSt;
779 output Integer mm_pos;
780 output Integer mm_sPos;
781 output Integer mm_ePos;
782 output Integer mm_linenr;
783 output Integer lineNrStart;
784 output Integer buffer;
785 output list<Integer> states;
786 output list<Token> errorTokens=inErrorTokens;
787 protected
788 Token tok;
789 Integer act,buffer2;
790 Integer c,baseCond;
791 algorithm
792 25461 mm_startSt := startSt;
793 25461 mm_currSt := currSt;
794 25461 mm_pos := pos;
795 25461 mm_sPos := sPos;
796 mm_ePos := ePos;
797 25461 mm_linenr := linenr;
798 lineNrStart := inLineNrStart;
799 25461 buffer := inBuffer;
800 25461 states := inStates;
801
802 25461 baseCond := LexTable.yy_base[mm_currSt];
803 if (debug==true) then
804 print("\nPROGRAM:{" + intString(cp) + "} ");
805 print("\nBUFFER:{" + intString(buffer) + "} ");
806 print("base:" + intString(baseCond) + " st:" + intString(mm_currSt)+" ");
807 end if;
808
809 25461 buffer := buffer+1;
810 25461 mm_pos := mm_pos+1;
811
812
2/2
✓ Branch 0 taken 1400 times.
✓ Branch 1 taken 24061 times.
25461 if (cp==10) then
813 1400 mm_linenr := mm_linenr+1;
814 1400 mm_sPos := 0;
815 else
816 24061 mm_sPos := mm_sPos+1;
817 end if;
818 if (debug==true) then
819 print("\n[Reading:'" + intStringChar(cp) +"' at p:" + intString(mm_pos-1) + " line:"+ intString(mm_linenr) + " rPos:" + intString(mm_sPos) +"]");
820 end if;
821 25461 c := LexTable.yy_ec[cp];
822
823 if (debug==true) then
824 print(" evalState Before[c" + intString(c) + ",s"+ intString(mm_currSt)+"]");
825 end if;
826 25461 (mm_currSt,c) := evalState(mm_currSt,c);
827 if (debug==true) then
828 print(" After[c" + intString(c) + ",s"+ intString(mm_currSt)+"]");
829 end if;
830
1/2
✓ Branch 0 taken 25461 times.
✗ Branch 1 not taken.
25461 if (mm_currSt>0) then
831 25461 mm_currSt := LexTable.yy_base[mm_currSt];
832 // print("BASE:"+ intString(mm_currSt)+"]");
833 25461 mm_currSt := LexTable.yy_nxt[mm_currSt + c];
834 // print("NEXT:"+ intString(mm_currSt)+"]");
835 else
836 ✗ mm_currSt := LexTable.yy_nxt[c];
837 end if;
838 25461 states := mm_currSt::states;
839
840 25461 baseCond := LexTable.yy_base[mm_currSt];
841
2/2
✓ Branch 0 taken 11431 times.
✓ Branch 1 taken 14030 times.
25461 if (baseCond==LexTable.yy_finish) then
842 if (debug==true) then
843 print("\n[RESTORE=" + intString(LexTable.yy_accept[mm_currSt]) + "]");
844 end if;
845
846 11431 (act, mm_currSt, mm_pos, mm_sPos, mm_linenr, buffer, bkBuffer, states) := findRule(fileContents, mm_currSt, mm_pos, mm_sPos, mm_ePos, mm_linenr, buffer, bkBuffer, states);
847
848 if (debug==true) then
849 print("\nFound rule: " + String(act));
850 end if;
851
852 11431 (tok,mm_startSt,buffer2,errorTokens) := action(act,mm_startSt,mm_currSt,mm_pos,mm_sPos,mm_ePos,mm_linenr,lineNrStart,buffer,fileName,fileContents,errorTokens);
853
854 if (debug==true) then
855 print("\nDid action");
856 end if;
857
858 11431 mm_currSt := mm_startSt;
859 11431 states := {};
860
861 /* Either a token was output (get new positions for next token). Or a whitespace was emitted. */
862
2/2
✓ Branch 0 taken 7277 times.
✓ Branch 1 taken 4154 times.
11431 if buffer <> buffer2 then
863 7277 mm_ePos := mm_sPos;
864 lineNrStart := linenr;
865 end if;
866 11431 buffer := buffer2;
867
868 resToken := match tok
869 case TOKEN(id=TokenId._NO_TOKEN) then tokens;
870 else tok::tokens;
871 end match;
872 if(debug) then
873 print("\n CountTokens:" + intString(listLength(resToken)));
874 end if;
875 else
876 14030 bkBuffer := 0; // consume the character
877 resToken := tokens;
878 end if;
879
880 end consume;
881
882
883 function findRule
884 input String fileContents;
885 input Integer currSt;
886 input Integer pos;
887 input Integer sPos;
888 input Integer mm_ePos;
889 input Integer linenr;
890 input Integer inBuffer;
891 input Integer inBkBuffer;
892 input list<Integer> inStates;
893 output Integer action;
894 output Integer mm_currSt;
895 output Integer mm_pos;
896 output Integer mm_sPos;
897 output Integer mm_linenr;
898 output Integer buffer;
899 output Integer bkBuffer;
900 output list<Integer> states;
901 protected
902 Integer lp,lp1,stCmp,cp;
903 Boolean st;
904 import arrayGet = MetaModelica.Dangerous.arrayGetNoBoundsChecking; // Bounds checked with debug=true
905 import stringGet = MetaModelica.Dangerous.stringGetNoBoundsChecking;
906 algorithm
907 mm_currSt := currSt;
908 mm_pos := pos;
909 mm_sPos := sPos;
910 mm_linenr := linenr;
911 buffer := inBuffer;
912 bkBuffer := inBkBuffer;
913 states := inStates;
914
915 16391 stCmp := listGet(states, 1);
916 16391 lp := LexTable.yy_accept[stCmp];
917 16391 lp1 := LexTable.yy_accept[stCmp+1];
918
919 16391 st := intGt(lp,0) and intLt(lp,lp1);
920
2/2
✓ Branch 0 taken 11431 times.
✓ Branch 1 taken 4960 times.
16391 if st then
921 if debug then
922 checkArrayModelica(LexTable.yy_accept,stCmp,sourceInfo());
923 checkArrayModelica(LexTable.yy_acclist,lp,sourceInfo());
924 end if;
925 lp := LexTable.yy_accept[stCmp];
926
1/2
✓ Branch 1 taken 11431 times.
✗ Branch 2 not taken.
11431 action := LexTable.yy_acclist[lp];
927 else
928 4960 cp := stringGet(fileContents,mm_pos-1);
929 4960 buffer := buffer-1;
930 4960 bkBuffer := bkBuffer+1;
931 4960 mm_pos := mm_pos - 1;
932 4960 mm_sPos := mm_sPos -1;
933
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 4620 times.
4960 if (cp==10) then
934 mm_sPos := mm_ePos;
935 340 mm_linenr := mm_linenr-1;
936 end if;
937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4960 times.
4960 mm_currSt::states := states;
938 4960 (action, mm_currSt, mm_pos, mm_sPos, mm_linenr, buffer, bkBuffer, states) := findRule(fileContents, mm_currSt, mm_pos, mm_sPos, mm_ePos, mm_linenr, buffer, bkBuffer, states);
939 end if;
940 end findRule;
941
942 function evalState
943 input Integer cState;
944 input Integer c;
945 output Integer new_state;
946 output Integer new_c;
947 protected
948 Integer cState1=cState;
949 Integer c1=c;
950 Integer val,val2,chk;
951 algorithm
952 41076 chk := LexTable.yy_base[cState1];
953 41076 chk := chk + c1;
954 41076 val := LexTable.yy_chk[chk];
955 val2 := LexTable.yy_base[cState1] + c1;
956
2/2
✓ Branch 0 taken 15615 times.
✓ Branch 1 taken 25461 times.
41076 if cState1<>val then
957 15615 cState1 := LexTable.yy_def[cState1];
958
2/2
✓ Branch 0 taken 10655 times.
✓ Branch 1 taken 4960 times.
15615 if cState1 >= LexTable.yy_limit then
959 10655 c1 := LexTable.yy_meta[c1];
960 end if;
961
1/2
✓ Branch 0 taken 15615 times.
✗ Branch 1 not taken.
15615 if (cState1>0) then
962 15615 (cState1,c1) := evalState(cState1,c1);
963 end if;
964 end if;
965 new_state := cState1;
966
1/2
✓ Branch 0 taken 41076 times.
✗ Branch 1 not taken.
41076 new_c := c1;
967 end evalState;
968
969 function checkArray<T>
970 input array<T> arr;
971 input Integer index;
972 input SourceInfo info;
973 protected
974 String filename;
975 Integer lineStart;
976 algorithm
977 ✗ if index<1 or index>arrayLength(arr) then
978 ✗ SOURCEINFO(fileName=filename, lineNumberStart=lineStart) := info;
979 ✗ print("\n[" + filename + ":" + String(lineStart) + "]: checkArray failed: arrayLength="+String(arrayLength(arr))+" index=" + String(index) + "\n");
980 ✗ fail();
981 end if;
982 end checkArray;
983
984 function checkArrayModelica
985 input array<Integer> arr;
986 input Integer index;
987 input SourceInfo info;
988 protected
989 String filename;
990 Integer lineStart;
991 algorithm
992 ✗ if index<1 or index>arrayLength(arr) then
993 ✗ SOURCEINFO(fileName=filename, lineNumberStart=lineStart) := info;
994 ✗ print("\n[" + filename + ":" + String(lineStart) + "]: checkArray failed: arrayLength="+String(arrayLength(arr))+" index=" + String(index) + "\n");
995 ✗ fail();
996 end if;
997 end checkArrayModelica;
998
999 package LexTable
1000 constant Integer yy_limit = 395;
1001 constant Integer yy_finish = 453;
1002 constant array<Integer> yy_acclist = MetaModelica.Dangerous.listArrayLiteral({
1003 115, 114, 1, 114, 2, 114, 114, 101, 114, 114,
1004 64, 114, 65, 114, 85, 114, 87, 114, 72, 114,
1005 86, 114, 97, 114, 94, 114, 100, 114, 75, 114,
1006 76, 114, 90, 114, 71, 114, 91, 114, 98, 114,
1007 66, 114, 67, 114, 93, 114, 98, 114, 98, 114,
1008 98, 114, 98, 114, 98, 114, 98, 114, 98, 114,
1009 98, 114, 98, 114, 98, 114, 98, 114, 98, 114,
1010 98, 114, 98, 114, 98, 114, 98, 114, 68, 114,
1011 69, 114, 109, 114, 110, 114, 109, 114, 113, 114,
1012 112, 114, 105, 114, 106, 114, 104, 105, 114, 105,
1013
1014 114, 1, 2, 82, 80, 81, 83, 5, 84, 107,
1015 111, 3, 100, 74, 73, 88, 89, 70, 92, 98,
1016 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
1017 98, 98, 98, 98, 98, 98, 98, 98, 34, 98,
1018 98, 36, 98, 98, 98, 98, 98, 46, 98, 98,
1019 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
1020 98, 98, 108, 102, 103, 99, 3, 4, 98, 7,
1021 98, 98, 98, 98, 98, 98, 98, 15, 98, 98,
1022 98, 98, 98, 21, 98, 98, 98, 98, 98, 98,
1023 98, 98, 32, 98, 98, 98, 98, 98, 98, 98,
1024
1025 98, 42, 98, 98, 98, 98, 98, 98, 98, 98,
1026 98, 98, 98, 98, 98, 98, 98, 98, 98, 98,
1027 98, 98, 98, 98, 5, 3, 98, 98, 98, 98,
1028 98, 98, 98, 98, 98, 17, 98, 18, 98, 98,
1029 98, 98, 98, 98, 98, 98, 31, 98, 98, 98,
1030 98, 98, 98, 98, 40, 98, 98, 98, 98, 98,
1031 98, 98, 98, 98, 98, 98, 98, 77, 98, 98,
1032 98, 98, 98, 98, 98, 56, 98, 57, 98, 58,
1033 98, 59, 98, 98, 98, 98, 98, 9, 98, 63,
1034 98, 10, 98, 98, 98, 98, 98, 98, 98, 98,
1035
1036 98, 98, 98, 98, 98, 29, 98, 30, 98, 98,
1037 98, 98, 98, 38, 98, 39, 98, 41, 98, 98,
1038 98, 43, 98, 98, 98, 98, 98, 98, 98, 98,
1039 98, 98, 98, 98, 98, 98, 60, 98, 98, 98,
1040 98, 98, 98, 98, 98, 98, 19, 98, 98, 98,
1041 98, 98, 98, 98, 98, 98, 35, 98, 78, 98,
1042 98, 98, 98, 47, 98, 98, 98, 98, 98, 98,
1043 52, 98, 53, 98, 98, 98, 62, 98, 96, 98,
1044 98, 61, 98, 98, 98, 11, 98, 98, 98, 98,
1045 98, 98, 98, 98, 98, 98, 26, 98, 98, 98,
1046
1047 37, 98, 98, 98, 98, 48, 98, 98, 50, 98,
1048 98, 98, 98, 98, 98, 98, 98, 13, 98, 98,
1049 98, 14, 98, 20, 98, 98, 98, 23, 98, 98,
1050 28, 98, 33, 98, 44, 98, 98, 45, 98, 98,
1051 98, 98, 98, 98, 6, 98, 98, 12, 98, 98,
1052 98, 98, 98, 98, 98, 49, 98, 51, 98, 54,
1053 98, 98, 95, 98, 8, 98, 98, 16, 98, 98,
1054 98, 25, 98, 98, 98, 98, 98, 22, 98, 98,
1055 55, 98, 98, 24, 98, 79, 98, 27, 98
1056 });
1057 constant array<Integer> yy_accept = MetaModelica.Dangerous.listArrayLiteral({
1058 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
1059 3, 5, 7, 8, 10, 11, 13, 15, 17, 19,
1060 21, 23, 25, 27, 29, 31, 33, 35, 37, 39,
1061 41, 43, 45, 47, 49, 51, 53, 55, 57, 59,
1062 61, 63, 65, 67, 69, 71, 73, 75, 77, 79,
1063 81, 83, 85, 87, 89, 91, 93, 95, 97, 100,
1064 102, 103, 104, 104, 104, 105, 106, 107, 108, 109,
1065 110, 111, 112, 113, 114, 114, 115, 116, 117, 118,
1066 119, 120, 121, 122, 123, 124, 125, 126, 127, 128,
1067 129, 130, 131, 132, 133, 134, 135, 136, 137, 138,
1068
1069 139, 141, 142, 144, 145, 146, 147, 148, 150, 151,
1070 152, 153, 154, 155, 156, 157, 158, 159, 160, 161,
1071 162, 163, 164, 165, 166, 167, 167, 168, 168, 168,
1072 169, 170, 172, 173, 174, 175, 176, 177, 178, 180,
1073 181, 182, 183, 184, 186, 187, 188, 189, 190, 191,
1074 192, 193, 195, 196, 197, 198, 199, 200, 201, 202,
1075 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
1076 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
1077 224, 225, 225, 226, 226, 227, 228, 229, 230, 231,
1078 232, 233, 234, 235, 236, 238, 240, 241, 242, 243,
1079
1080 244, 245, 246, 247, 249, 250, 251, 252, 253, 254,
1081 255, 257, 258, 259, 260, 261, 262, 263, 264, 265,
1082 266, 267, 268, 270, 271, 272, 273, 274, 275, 276,
1083 278, 280, 282, 284, 285, 286, 287, 288, 290, 292,
1084 294, 295, 296, 297, 298, 299, 300, 301, 302, 303,
1085 304, 305, 306, 308, 310, 311, 312, 313, 314, 316,
1086 318, 320, 321, 322, 324, 325, 326, 327, 328, 329,
1087 330, 331, 332, 333, 334, 335, 336, 337, 339, 340,
1088 341, 342, 343, 344, 345, 346, 347, 349, 350, 351,
1089 352, 353, 354, 355, 356, 357, 359, 361, 362, 363,
1090
1091 364, 366, 367, 368, 369, 370, 371, 373, 375, 376,
1092 377, 379, 381, 382, 384, 385, 386, 388, 389, 390,
1093 391, 392, 393, 394, 395, 396, 397, 399, 400, 401,
1094 403, 404, 405, 406, 408, 409, 411, 412, 413, 414,
1095 415, 416, 417, 418, 420, 421, 422, 424, 426, 427,
1096 428, 430, 431, 433, 435, 437, 438, 440, 441, 442,
1097 443, 444, 445, 447, 448, 450, 451, 452, 453, 454,
1098 455, 456, 458, 460, 462, 463, 465, 467, 468, 470,
1099 471, 472, 474, 475, 476, 477, 478, 480, 481, 483,
1100 484, 486, 488, 490, 490
1101
1102 });
1103 constant array<Integer> yy_ec = MetaModelica.Dangerous.listArrayLiteral({
1104 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
1105 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
1106 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1107 1, 5, 6, 7, 6, 6, 6, 6, 8, 9,
1108 10, 11, 12, 13, 14, 15, 16, 17, 17, 17,
1109 17, 17, 17, 17, 17, 17, 17, 18, 19, 20,
1110 21, 22, 6, 6, 23, 23, 23, 23, 24, 23,
1111 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1112 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1113 25, 26, 27, 28, 23, 1, 29, 30, 31, 32,
1114
1115 33, 34, 35, 36, 37, 23, 38, 39, 40, 41,
1116 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
1117 52, 53, 54, 6, 55, 1, 1, 1, 1, 1,
1118 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1119 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1120 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1121 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1122 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1123 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1124 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1125
1126 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1127 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1128 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1129 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1130 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1131 1, 1, 1, 1, 1
1132 });
1133 constant array<Integer> yy_meta = MetaModelica.Dangerous.listArrayLiteral({
1134 1, 1, 1, 1, 2, 2, 3, 3, 2, 2,
1135 2, 2, 2, 2, 2, 2, 4, 2, 2, 2,
1136 5, 2, 4, 4, 2, 5, 2, 2, 6, 6,
1137 4, 4, 4, 6, 4, 4, 4, 4, 4, 4,
1138 6, 4, 4, 4, 6, 4, 4, 4, 6, 4,
1139 4, 6, 4, 2, 2
1140 });
1141 constant array<Integer> yy_base = MetaModelica.Dangerous.listArrayLiteral({
1142 0, 0, 53, 54, 449, 448, 55, 56, 450, 453,
1143 64, 453, 446, 453, 422, 453, 453, 453, 453, 453,
1144 453, 56, 60, 62, 57, 453, 39, 426, 425, 0,
1145 453, 453, 453, 44, 35, 48, 55, 60, 68, 62,
1146 403, 402, 401, 69, 77, 409, 46, 79, 72, 453,
1147 453, 453, 453, 425, 453, 453, 453, 453, 453, 93,
1148 118, 453, 113, 0, 453, 453, 453, 453, 109, 453,
1149 453, 453, 110, 113, 124, 453, 453, 453, 453, 453,
1150 453, 0, 405, 103, 397, 405, 408, 395, 95, 389,
1151 403, 387, 116, 384, 102, 392, 389, 387, 383, 386,
1152
1153 0, 383, 113, 383, 392, 376, 118, 0, 375, 388,
1154 121, 378, 68, 126, 374, 388, 384, 368, 372, 122,
1155 367, 453, 453, 146, 453, 162, 144, 166, 396, 395,
1156 369, 0, 368, 378, 379, 361, 121, 369, 0, 374,
1157 368, 370, 373, 0, 361, 371, 370, 365, 351, 367,
1158 345, 0, 363, 133, 346, 359, 343, 347, 356, 0,
1159 343, 350, 127, 341, 347, 142, 337, 344, 349, 339,
1160 347, 340, 330, 344, 329, 334, 341, 340, 331, 332,
1161 334, 352, 351, 350, 349, 320, 317, 325, 324, 315,
1162 327, 312, 317, 312, 0, 145, 313, 322, 307, 312,
1163
1164 143, 319, 312, 0, 303, 304, 303, 310, 301, 298,
1165 0, 305, 314, 302, 296, 292, 300, 309, 297, 299,
1166 302, 297, 0, 288, 301, 302, 285, 300, 276, 0,
1167 0, 0, 0, 294, 289, 288, 295, 0, 0, 0,
1168 292, 156, 289, 288, 286, 283, 272, 272, 279, 283,
1169 282, 272, 0, 0, 275, 264, 277, 280, 0, 0,
1170 0, 261, 270, 0, 259, 263, 269, 270, 273, 270,
1171 269, 267, 259, 266, 255, 255, 251, 0, 252, 245,
1172 244, 243, 248, 259, 239, 239, 0, 252, 236, 254,
1173 240, 252, 234, 250, 236, 0, 0, 238, 234, 222,
1174
1175 0, 245, 240, 225, 232, 223, 0, 0, 240, 235,
1176 0, 0, 234, 0, 230, 228, 222, 216, 225, 220,
1177 227, 218, 219, 210, 215, 225, 0, 215, 212, 0,
1178 207, 222, 218, 0, 216, 0, 215, 202, 217, 203,
1179 204, 201, 197, 0, 200, 203, 0, 0, 210, 201,
1180 0, 198, 0, 0, 0, 189, 0, 190, 202, 200,
1181 202, 195, 0, 185, 0, 188, 153, 152, 156, 164,
1182 159, 0, 0, 0, 155, 0, 0, 161, 0, 159,
1183 150, 0, 148, 154, 156, 131, 0, 91, 0, 39,
1184 0, 0, 0, 453, 201, 207, 213, 218, 221, 225
1185
1186 });
1187 constant array<Integer> yy_def = MetaModelica.Dangerous.listArrayLiteral({
1188 394, 1, 395, 395, 396, 396, 397, 397, 394, 394,
1189 394, 394, 394, 394, 398, 394, 394, 394, 394, 394,
1190 394, 394, 394, 394, 394, 394, 394, 394, 394, 399,
1191 394, 394, 394, 399, 399, 399, 399, 399, 399, 399,
1192 399, 399, 399, 399, 399, 399, 399, 399, 399, 394,
1193 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1194 394, 394, 398, 400, 394, 394, 394, 394, 394, 394,
1195 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1196 394, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1197 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1198
1199 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1200 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1201 399, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1202 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1203 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1204 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1205 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1206 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1207 399, 394, 394, 394, 394, 399, 399, 399, 399, 399,
1208 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1209
1210 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1211 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1212 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1213 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1214 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1215 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1216 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1217 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1218 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1219 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1220
1221 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1222 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1223 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1224 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1225 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1226 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1227 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1228 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1229 399, 399, 399, 399, 399, 399, 399, 399, 399, 399,
1230 399, 399, 399, 0, 394, 394, 394, 394, 394, 394
1231
1232 });
1233 constant array<Integer> yy_nxt = MetaModelica.Dangerous.listArrayLiteral({
1234 10, 11, 12, 13, 11, 10, 14, 15, 16, 17,
1235 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
1236 28, 29, 30, 30, 31, 10, 32, 33, 34, 35,
1237 36, 37, 38, 39, 30, 30, 40, 30, 41, 42,
1238 43, 44, 45, 30, 46, 47, 48, 30, 30, 49,
1239 30, 30, 30, 50, 51, 53, 53, 58, 58, 78,
1240 79, 59, 59, 54, 54, 61, 65, 66, 61, 67,
1241 71, 68, 69, 85, 76, 72, 73, 77, 74, 86,
1242 60, 60, 83, 70, 84, 75, 87, 89, 91, 88,
1243 393, 90, 115, 116, 75, 101, 96, 168, 92, 123,
1244
1245 93, 102, 103, 94, 97, 111, 98, 120, 121, 99,
1246 95, 107, 169, 108, 117, 100, 109, 110, 124, 61,
1247 125, 112, 61, 118, 113, 69, 127, 73, 138, 74,
1248 119, 392, 126, 128, 132, 129, 75, 129, 64, 139,
1249 130, 126, 128, 133, 147, 75, 143, 144, 148, 155,
1250 161, 165, 123, 156, 179, 157, 170, 171, 180, 215,
1251 127, 191, 391, 145, 162, 166, 192, 128, 172, 216,
1252 219, 124, 173, 182, 206, 182, 128, 184, 183, 184,
1253 207, 245, 185, 251, 283, 390, 389, 252, 220, 388,
1254 387, 386, 385, 384, 246, 383, 382, 381, 380, 379,
1255
1256 284, 52, 52, 52, 52, 52, 52, 55, 55, 55,
1257 55, 55, 55, 57, 57, 57, 57, 57, 57, 63,
1258 378, 63, 63, 63, 82, 377, 82, 63, 376, 63,
1259 63, 375, 374, 373, 372, 371, 370, 369, 368, 367,
1260 366, 365, 364, 363, 362, 361, 360, 359, 358, 357,
1261 356, 355, 354, 353, 352, 351, 350, 349, 348, 347,
1262 346, 345, 344, 343, 342, 341, 340, 339, 338, 337,
1263 336, 335, 334, 333, 332, 331, 330, 329, 328, 327,
1264 326, 325, 324, 323, 322, 321, 320, 319, 318, 317,
1265 316, 315, 314, 313, 312, 311, 310, 309, 308, 307,
1266
1267 306, 305, 304, 303, 302, 301, 300, 299, 298, 297,
1268 296, 295, 294, 293, 292, 291, 290, 289, 288, 287,
1269 286, 285, 282, 281, 280, 279, 278, 277, 276, 275,
1270 274, 273, 272, 271, 270, 269, 268, 267, 266, 265,
1271 264, 263, 262, 261, 260, 259, 258, 257, 256, 255,
1272 254, 253, 250, 249, 248, 247, 244, 243, 242, 241,
1273 240, 239, 238, 237, 236, 185, 185, 183, 183, 235,
1274 234, 233, 232, 231, 230, 229, 228, 227, 226, 225,
1275 224, 223, 222, 221, 218, 217, 214, 213, 212, 211,
1276 210, 209, 208, 205, 204, 203, 202, 201, 200, 199,
1277
1278 198, 197, 196, 195, 194, 193, 190, 189, 188, 187,
1279 186, 130, 130, 181, 178, 177, 176, 175, 174, 167,
1280 164, 163, 160, 159, 158, 154, 153, 152, 151, 150,
1281 149, 146, 142, 141, 140, 137, 136, 135, 134, 131,
1282 122, 114, 106, 105, 104, 81, 80, 64, 62, 394,
1283 56, 56, 9, 394, 394, 394, 394, 394, 394, 394,
1284 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1285 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1286 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1287 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1288
1289 394, 394, 394, 394, 394, 394, 394, 394
1290 });
1291 constant array<Integer> yy_chk = MetaModelica.Dangerous.listArrayLiteral({
1292 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1293 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1294 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1295 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1296 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1297 1, 1, 1, 1, 1, 3, 4, 7, 8, 27,
1298 27, 7, 8, 3, 4, 11, 22, 22, 11, 22,
1299 23, 22, 22, 35, 25, 23, 24, 25, 24, 35,
1300 7, 8, 34, 22, 34, 24, 36, 37, 38, 36,
1301 390, 37, 47, 47, 24, 40, 39, 113, 38, 60,
1302
1303 38, 40, 40, 38, 39, 45, 39, 49, 49, 39,
1304 38, 44, 113, 44, 48, 39, 44, 44, 60, 61,
1305 63, 45, 61, 48, 45, 69, 73, 74, 89, 74,
1306 48, 388, 69, 73, 84, 75, 74, 75, 63, 89,
1307 75, 69, 73, 84, 95, 74, 93, 93, 95, 103,
1308 107, 111, 124, 103, 120, 103, 114, 114, 120, 163,
1309 127, 137, 386, 93, 107, 111, 137, 127, 114, 163,
1310 166, 124, 114, 126, 154, 126, 127, 128, 126, 128,
1311 154, 196, 128, 201, 242, 385, 384, 201, 166, 383,
1312 381, 380, 378, 375, 196, 371, 370, 369, 368, 367,
1313
1314 242, 395, 395, 395, 395, 395, 395, 396, 396, 396,
1315 396, 396, 396, 397, 397, 397, 397, 397, 397, 398,
1316 366, 398, 398, 398, 399, 364, 399, 400, 362, 400,
1317 400, 361, 360, 359, 358, 356, 352, 350, 349, 346,
1318 345, 343, 342, 341, 340, 339, 338, 337, 335, 333,
1319 332, 331, 329, 328, 326, 325, 324, 323, 322, 321,
1320 320, 319, 318, 317, 316, 315, 313, 310, 309, 306,
1321 305, 304, 303, 302, 300, 299, 298, 295, 294, 293,
1322 292, 291, 290, 289, 288, 286, 285, 284, 283, 282,
1323 281, 280, 279, 277, 276, 275, 274, 273, 272, 271,
1324
1325 270, 269, 268, 267, 266, 265, 263, 262, 258, 257,
1326 256, 255, 252, 251, 250, 249, 248, 247, 246, 245,
1327 244, 243, 241, 237, 236, 235, 234, 229, 228, 227,
1328 226, 225, 224, 222, 221, 220, 219, 218, 217, 216,
1329 215, 214, 213, 212, 210, 209, 208, 207, 206, 205,
1330 203, 202, 200, 199, 198, 197, 194, 193, 192, 191,
1331 190, 189, 188, 187, 186, 185, 184, 183, 182, 181,
1332 180, 179, 178, 177, 176, 175, 174, 173, 172, 171,
1333 170, 169, 168, 167, 165, 164, 162, 161, 159, 158,
1334 157, 156, 155, 153, 151, 150, 149, 148, 147, 146,
1335
1336 145, 143, 142, 141, 140, 138, 136, 135, 134, 133,
1337 131, 130, 129, 121, 119, 118, 117, 116, 115, 112,
1338 110, 109, 106, 105, 104, 102, 100, 99, 98, 97,
1339 96, 94, 92, 91, 90, 88, 87, 86, 85, 83,
1340 54, 46, 43, 42, 41, 29, 28, 15, 13, 9,
1341 6, 5, 394, 394, 394, 394, 394, 394, 394, 394,
1342 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1343 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1344 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1345 394, 394, 394, 394, 394, 394, 394, 394, 394, 394,
1346
1347 394, 394, 394, 394, 394, 394, 394, 394
1348 });
1349
1350 end LexTable;
1351
1352
1353 public
1354
1355 function modelicaDiffTokenEq
1356 import LexerModelicaDiff.{Token,TokenId,tokenContent};
1357 input Token ta,tb;
1358 output Boolean b;
1359 protected
1360 LexerModelicaDiff.TokenId ida,idb;
1361 algorithm
1362 8339 LexerModelicaDiff.TOKEN(id=ida) := ta;
1363 8339 LexerModelicaDiff.TOKEN(id=idb) := tb;
1364
2/2
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 8322 times.
8339 if ida <> idb then
1365 b := false;
1366 17 return;
1367 end if;
1368 b := match ida
1369 3506 case TokenId.IDENT then tokenContentEq(ta,tb);
1370 288 case TokenId.UNSIGNED_INTEGER then tokenContentEq(ta,tb);
1371 case TokenId.UNSIGNED_REAL
1372 93 then stringReal(tokenContent(ta))==stringReal(tokenContent(tb));
1373 case TokenId.BLOCK_COMMENT
1374 12 then valueEq(blockCommentCanonical(ta),blockCommentCanonical(tb));
1375 10 case TokenId.LINE_COMMENT then tokenContentEq(ta,tb);
1376 case TokenId.STRING
1377 algorithm
1378 39 b := tokenContentEq(ta,tb);
1379
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 8 times.
39 if not b then
1380
1/2
✗ Branch 2 not taken.
✓ Branch 3 taken 31 times.
31 b := if 0<>StringUtil.findChar(tokenContent(ta), stringCharInt("\n")) then valueEq(blockCommentCanonical(ta),blockCommentCanonical(tb)) else false;
1381 end if;
1382 then b;
1383 case TokenId.WHITESPACE then true; // tokenContent(ta)==tokenContent(tb);
1384 else true;
1385 end match;
1386 end modelicaDiffTokenEq;
1387
1388 function modelicaDiffTokenWhitespace
1389 import LexerModelicaDiff.{Token,TokenId};
1390 input Token t;
1391 output Boolean b;
1392 protected
1393 LexerModelicaDiff.TokenId id;
1394 algorithm
1395 3658 LexerModelicaDiff.TOKEN(id=id) := t;
1396
4/4
✓ Branch 0 taken 3618 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 2166 times.
✓ Branch 3 taken 1452 times.
3658 b := id==TokenId.BLOCK_COMMENT or id==TokenId.LINE_COMMENT or id==TokenId.WHITESPACE or id==TokenId.NEWLINE;
1397 end modelicaDiffTokenWhitespace;
1398
1399 function filterModelicaDiff
1400 import LexerModelicaDiff.{Token,TokenId,tokenContent,TOKEN};
1401 import DiffAlgorithm.Diff;
1402 input list<tuple<Diff, list<Token>>> diffs;
1403 input Boolean removeWhitespace=true;
1404 output list<tuple<Diff, list<Token>>> odiffs;
1405 protected
1406 list<String> addedLineComments, removedLineComments;
1407 list<list<String>> addedBlockComments, removedBlockComments;
1408 list<tuple<Diff, Token>> simpleDiff, tmp, rest;
1409 Boolean lastIsNewline;
1410 Integer depth;
1411 algorithm
1412 // No changes are easy
1413 () := match diffs
1414 case {(Diff.Equal,_)}
1415 algorithm
1416 odiffs := diffs;
1417 ✗ return;
1418 then ();
1419 else ();
1420 end match;
1421
1422 ✗ odiffs := listReverse(match e
1423 local
1424 list<Token> ts;
1425 ✗ case (Diff.Delete,ts as {TOKEN(id=TokenId.WHITESPACE)}) then (Diff.Equal,ts);
1426 ✗ case (Diff.Delete,ts as {TOKEN(id=TokenId.NEWLINE)}) then (Diff.Equal,ts);
1427 else e;
1428 end match
1429
1430 for e guard(
1431 match e
1432 // Single addition of whitespace, not followed by another addition
1433 // is suspected garbage added by OMC.
1434 ✗ case (Diff.Add,{TOKEN(id=TokenId.WHITESPACE)}) then not removeWhitespace;
1435 ✗ case (Diff.Add,{TOKEN(id=TokenId.NEWLINE)}) then not removeWhitespace;
1436 case (_,{}) then false;
1437 else true;
1438 end match
1439 ) in diffs);
1440
1441 // Convert from multiple additions per item to one per item
1442 // Costs more memory, but is easier to transform
1443 ✗ simpleDiff := listAppend(
1444 match e
1445 local
1446 list<Token> ts;
1447 ✗ case (Diff.Add,ts) then list((Diff.Add,t) for t in ts);
1448 ✗ case (Diff.Equal,ts) then list((Diff.Equal,t) for t in ts);
1449 ✗ case (Diff.Delete,ts) then list((Diff.Delete,t) for t in ts);
1450 end match
1451 for e in odiffs);
1452
1453 tmp := {};
1454 lastIsNewline := false;
1455 depth := 2;
1456 ✗ while not listEmpty(simpleDiff) loop
1457 (lastIsNewline,simpleDiff,tmp) := match simpleDiff
1458 local
1459 tuple<Diff, Token> e,e1,e2;
1460 Token t,t1,t2,tk3,tk4,tk5;
1461 TokenId t3,t4,t5;
1462 Diff d1,d2,d3,d4,d5;
1463 // Do not delete whitespace in-between two tokens
1464 ✗ case (e1 as (Diff.Equal,_))::(Diff.Delete,t1 as TOKEN(id=TokenId.NEWLINE))::(Diff.Delete,t2 as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t1)::(Diff.Equal,t2)::e2::rest,tmp);
1465 ✗ case (e1 as (Diff.Equal,_))::(Diff.Delete,t as TOKEN(id=TokenId.WHITESPACE))::(e2 as (Diff.Equal,_))::rest then (false,e1::(Diff.Equal,t)::e2::rest,tmp);
1466 case (e1 as (Diff.Equal,TOKEN(id=t3)))::rest
1467 guard t3<>TokenId.WHITESPACE and t3<>TokenId.NEWLINE and deleteWhitespaceFollowedByEqualNonWhitespace(rest)
1468 algorithm
1469 ✗ (_,rest) := deleteWhitespaceFollowedByEqualNonWhitespace(rest);
1470 ✗ then (false,e1::rest,tmp);
1471
1472 // Do not delete+add the same token just because there is whitespace added
1473 case (d1,t1)::(Diff.Add,TOKEN(id=t3))::(Diff.Add,TOKEN(id=t4))::(Diff.Add,TOKEN(id=t5))::(d2,t2)::rest
1474 guard ((d1==Diff.Add and d2==Diff.Delete) or (d2==Diff.Add and d1==Diff.Delete)) and modelicaDiffTokenEq(t1,t2)
1475 and (t3==TokenId.NEWLINE or t3 == TokenId.WHITESPACE) and (t4==TokenId.NEWLINE or t4 == TokenId.WHITESPACE) and (t5==TokenId.NEWLINE or t5 == TokenId.WHITESPACE)
1476 ✗ then (false,(Diff.Equal,t1)::rest,tmp);
1477 case (d1,t1)::(Diff.Add,TOKEN(id=t3))::(Diff.Add,TOKEN(id=t4))::(d2,t2)::rest
1478 guard ((d1==Diff.Add and d2==Diff.Delete) or (d2==Diff.Add and d1==Diff.Delete)) and modelicaDiffTokenEq(t1,t2)
1479 and (t3==TokenId.NEWLINE or t3 == TokenId.WHITESPACE) and (t4==TokenId.NEWLINE or t4 == TokenId.WHITESPACE)
1480 ✗ then (false,(Diff.Equal,t1)::rest,tmp);
1481 case (d1,t1)::(Diff.Add,TOKEN(id=t3))::(d2,t2)::rest
1482 guard ((d1==Diff.Add and d2==Diff.Delete) or (d2==Diff.Add and d1==Diff.Delete)) and modelicaDiffTokenEq(t1,t2)
1483 and (t3==TokenId.NEWLINE or t3 == TokenId.WHITESPACE)
1484 ✗ then (false,(Diff.Equal,t1)::rest,tmp);
1485
1486 // Odd case of Delete token + equals whitespace + Add token again... Do Equal token + equal whitespace
1487 case (d1,t1)::(d3,tk3 as TOKEN(id=t3))::(d4,tk4 as TOKEN(id=t4))::(d5,tk5 as TOKEN(id=t5))::(d2,t2)::rest
1488 guard ((d1==Diff.Add and d2==Diff.Delete) or (d2==Diff.Add and d1==Diff.Delete)) and modelicaDiffTokenEq(t1,t2)
1489 and (d3==Diff.Equal or d3==Diff.Delete) and (d4==Diff.Equal or d4==Diff.Delete) and (d5==Diff.Equal or d5==Diff.Delete)
1490 and (t3==TokenId.NEWLINE or t3 == TokenId.WHITESPACE) and (t4==TokenId.NEWLINE or t4 == TokenId.WHITESPACE) and (t5==TokenId.NEWLINE or t5 == TokenId.WHITESPACE)
1491 ✗ then (false,(Diff.Equal,t1)::(Diff.Equal,tk3)::(Diff.Equal,tk4)::(Diff.Equal,tk5)::rest,tmp);
1492 case (d1,t1)::(d3,tk3 as TOKEN(id=t3))::(d4,tk4 as TOKEN(id=t4))::(d2,t2)::rest
1493 guard ((d1==Diff.Add and d2==Diff.Delete) or (d2==Diff.Add and d1==Diff.Delete)) and modelicaDiffTokenEq(t1,t2)
1494 and (d3==Diff.Equal or d3==Diff.Delete) and (d4==Diff.Equal or d4==Diff.Delete)
1495 and (t3==TokenId.NEWLINE or t3 == TokenId.WHITESPACE) and (t4==TokenId.NEWLINE or t4 == TokenId.WHITESPACE)
1496 ✗ then (false,(Diff.Equal,t1)::(Diff.Equal,tk3)::(Diff.Equal,tk4)::rest,tmp);
1497 case (d1,t1)::(d3,tk3 as TOKEN(id=t3))::(d2,t2)::rest
1498 guard ((d1==Diff.Add and d2==Diff.Delete) or (d2==Diff.Add and d1==Diff.Delete)) and modelicaDiffTokenEq(t1,t2)
1499 and (d3==Diff.Equal or d3==Diff.Delete)
1500 and (t3==TokenId.NEWLINE or t3 == TokenId.WHITESPACE)
1501 ✗ then (false,(Diff.Equal,t1)::(Diff.Equal,tk3)::rest,tmp);
1502
1503 case (Diff.Add,TOKEN(id=TokenId.NEWLINE))::(Diff.Add,TOKEN(id=TokenId.WHITESPACE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_)
1504 then (false,rest,tmp);
1505 case (Diff.Add,TOKEN(id=TokenId.NEWLINE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_)
1506 then (false,rest,tmp);
1507 case (e as (_,TOKEN(id=TokenId.NEWLINE)))::(Diff.Add,TOKEN(id=TokenId.NEWLINE))::rest
1508 then (false,e::rest,tmp);
1509 ✗ case (e as (_,TOKEN(id=TokenId.NEWLINE)))::rest then (true,rest,e::tmp);
1510 case (Diff.Add,TOKEN(id=TokenId.WHITESPACE))::(e as (Diff.Add,_))::rest guard lastIsNewline
1511 ✗ then (false,rest,e::
1512 (Diff.Add,TOKEN("WHITESPACE",TokenId.WHITESPACE,sum(" " for i in 1:depth),1,depth,0,0,0,0))
1513 ::tmp);
1514 case (Diff.Add,TOKEN(id=TokenId.WHITESPACE))::(rest as (_,TOKEN(id=TokenId.NEWLINE))::_) guard lastIsNewline
1515 then (true,rest,tmp);
1516 case (e as (_,t as TOKEN(id=TokenId.WHITESPACE)))::rest guard lastIsNewline
1517 algorithm
1518 ✗ TOKEN(length=depth) := t;
1519 ✗ then (false,rest,e::tmp);
1520 ✗ case e::rest then (false,rest,e::tmp);
1521 end match;
1522 end while;
1523 ✗ simpleDiff := listReverse(tmp);
1524
1525 ✗ addedLineComments := list(tokenContent(tuple22(e)) for e guard Diff.Add==tuple21(e) and isLineComment(tuple22(e)) in simpleDiff);
1526 ✗ removedLineComments := list(tokenContent(tuple22(e)) for e guard Diff.Delete==tuple21(e) and isLineComment(tuple22(e)) in simpleDiff);
1527
1528 ✗ addedBlockComments := list(blockCommentCanonical(tuple22(e)) for e guard Diff.Add==tuple21(e) and isBlockComment(tuple22(e)) in simpleDiff);
1529 ✗ removedBlockComments := list(blockCommentCanonical(tuple22(e)) for e guard Diff.Delete==tuple21(e) and isBlockComment(tuple22(e)) in simpleDiff);
1530
1531 ✗ simpleDiff := list(
1532 match e
1533 local
1534 Token t;
1535 ✗ case (Diff.Delete,t as TOKEN(id=TokenId.LINE_COMMENT)) then (if listMember(tokenContent(t), addedLineComments) then (Diff.Equal,t) else e);
1536 ✗ case (Diff.Delete,t as TOKEN(id=TokenId.BLOCK_COMMENT)) then (if listMember(blockCommentCanonical(t), addedBlockComments) then (Diff.Equal,t) else e);
1537 else e;
1538 end match
1539 for e guard(
1540 match e
1541 local
1542 Token t;
1543 ✗ case (Diff.Add,t as TOKEN(id=TokenId.LINE_COMMENT)) then not listMember(tokenContent(t), removedLineComments);
1544 ✗ case (Diff.Add,t as TOKEN(id=TokenId.BLOCK_COMMENT)) then not listMember(blockCommentCanonical(t), removedBlockComments);
1545 else true;
1546 end match
1547 ) in simpleDiff);
1548
1549 ✗ odiffs := list(
1550 match e
1551 local
1552 Diff d;
1553 Token t;
1554 ✗ case (d,t) then (d,{t});
1555 end match
1556 for e in simpleDiff);
1557 end filterModelicaDiff;
1558
1559 function isBlockComment
1560 import LexerModelicaDiff.{Token,TokenId,TOKEN};
1561 input Token t;
1562 output Boolean b;
1563 algorithm
1564 b := match t case TOKEN(id=TokenId.BLOCK_COMMENT) then true; else false; end match;
1565 end isBlockComment;
1566
1567 function isLineComment
1568 import LexerModelicaDiff.{Token,TokenId,TOKEN};
1569 input Token t;
1570 output Boolean b;
1571 algorithm
1572 b := match t case TOKEN(id=TokenId.LINE_COMMENT) then true; else false; end match;
1573 end isLineComment;
1574
1575 function tuple21<A,B>
1576 input tuple<A,B> t;
1577 output A a;
1578 algorithm
1579 ✗ (a,_) := t;
1580 end tuple21;
1581
1582 function tuple22<A,B>
1583 input tuple<A,B> t;
1584 output B b;
1585 algorithm
1586 ✗ (_,b) := t;
1587 end tuple22;
1588
1589 function blockCommentCanonical
1590 import LexerModelicaDiff.{Token,tokenContent};
1591 input Token t;
1592 output list<String> lines;
1593 algorithm
1594 // Canonical representation trims whitespace from each line
1595
4/4
✓ Branch 2 taken 240 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 240 times.
✓ Branch 5 taken 48 times.
288 lines := list(System.trim(s) for s in System.strtok(tokenContent(t),"\n"));
1596 end blockCommentCanonical;
1597
1598 function deleteWhitespaceFollowedByEqualNonWhitespace
1599 import LexerModelicaDiff.{Token,TokenId,TOKEN};
1600 import DiffAlgorithm.Diff;
1601 input list<tuple<Diff, Token>> inRest;
1602 output Boolean b;
1603 output list<tuple<Diff, Token>> result;
1604 protected
1605 tuple<Diff, Token> head;
1606 Diff diff;
1607 Token t;
1608 TokenId id;
1609 list<tuple<Diff, Token>> rest;
1610 Boolean foundWS=false, foundNL=false;
1611 algorithm
1612 rest := inRest;
1613 result := {};
1614 ✗ while not listEmpty(rest) loop
1615 ✗ head as (diff,t as TOKEN(id=id)) := listHead(rest);
1616 ✗ if diff <> Diff.Delete then
1617 break;
1618 end if;
1619 ✗ rest := listRest(rest);
1620 ✗ if id==TokenId.WHITESPACE and not foundWS then
1621 foundWS := true;
1622 ✗ result := (Diff.Equal,t)::result;
1623 elseif id==TokenId.NEWLINE then
1624 foundNL := true;
1625 break;
1626 else
1627 result := head :: result;
1628 end if;
1629 end while;
1630 ✗ if (not foundWS) or foundNL then
1631 // If we find a newline, we probably went too far.
1632 b := false;
1633 result := {};
1634 ✗ return;
1635 end if;
1636 () := match rest
1637 case (Diff.Equal,t)::_ then ();
1638 else
1639 algorithm
1640 b := false;
1641 result := {};
1642 ✗ return;
1643 then fail();
1644 end match;
1645 b := true;
1646 ✗ for i in result loop
1647 rest := i::rest;
1648 end for;
1649 result := rest;
1650 end deleteWhitespaceFollowedByEqualNonWhitespace;
1651
1652 function reportErrors
1653 import LexerModelicaDiff.{Token,TokenId,tokenContent,tokenSourceInfo};
1654 input list<Token> tokens;
1655 protected
1656 Integer i=0;
1657 String content;
1658 algorithm
1659
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 for t in tokens loop
1660 ✗ i := i+1;
1661 ✗ if i>10 then
1662 ✗ Error.addMessage(Error.SCANNER_ERROR_LIMIT, {});
1663 end if;
1664 ✗ content := tokenContent(t);
1665 ✗ Error.addSourceMessage(Error.SCANNER_ERROR, {StringUtil.convertCharNonAsciiToHex(content)}, tokenSourceInfo(t));
1666 end for;
1667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92 times.
92 if not listEmpty(tokens) then
1668 ✗ fail();
1669 end if;
1670 end reportErrors;
1671
1672 annotation(__OpenModelica_Interface="backend_tools");
1673
1674
1675 end LexerModelicaDiff;
1676