-
Notifications
You must be signed in to change notification settings - Fork 298
/
LexerModelicaDiff.mo
1674 lines (1576 loc) · 67.1 KB
/
LexerModelicaDiff.mo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
encapsulated package LexerModelicaDiff "Automatically generated lexer based on flex, generated OMCCp v0.11.0 OpenModelica lexer and parser generator (2015)"
/*
Template for Lexer Code
replace keywords:
%LexerCode
%time
%Token
%Lexer
%LexTable
%constant
%nameSpan
%functions
%caseAction
*/
import System;
constant Boolean debug = false;
replaceable package LexTable
constant Integer yy_limit;
constant Integer yy_finish;
constant Integer yy_acclist[:];
constant Integer yy_accept[:];
constant Integer yy_ec[:];
constant Integer yy_meta[:];
constant Integer yy_base[:];
constant Integer yy_def[:];
constant Integer yy_nxt[:];
constant Integer yy_chk[:];
end LexTable;
function scan "Scan starts the lexical analysis, load the tables and consume the program to output the tokens"
input String fileName "input source code file";
output list<Token> tokens "return list of tokens";
output list<Token> errorTokens;
protected
String contents;
algorithm
contents := System.readFile(fileName);
(tokens, errorTokens) := lex(fileName,contents);
end scan;
function scanString "Scan starts the lexical analysis, load the tables and consume the program to output the tokens"
input String fileSource "input source code file";
output list<Token> tokens "return list of tokens";
output list<Token> errorTokens;
algorithm
(tokens, errorTokens) := lex("<StringSource>",fileSource);
end scanString;
import DiffAlgorithm;
protected
import Error;
import StringUtil;
public
function action
input Integer act;
input Integer startSt;
input Integer mm_currSt,mm_pos,mm_sPos,mm_ePos,mm_linenr,lineNrStart;
input Integer buffer;
input Boolean debug;
input String fileNm;
input String fileContents;
input list<Token> inErrorTokens;
output Token token;
output Integer mm_startSt;
output Integer bufferRet;
output list<Token> errorTokens=inErrorTokens;
protected
SourceInfo info;
String sToken;
algorithm
mm_startSt := startSt;
// nameSpan := 255;
bufferRet := 0;
(token) := match (act)
local
Token tok;
case (1) // #line 36 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.WHITESPACE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (2) // #line 37 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.NEWLINE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (3) // #line 38 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.UNSIGNED_REAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (4) // #line 39 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.UNSIGNED_REAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (5) // #line 40 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.UNSIGNED_REAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (6) // #line 41 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ALGORITHM,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (7) // #line 42 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.AND,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (8) // #line 43 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ANNOTATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (9) // #line 44 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.BLOCK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (10) // #line 45 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.CLASS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (11) // #line 46 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.CONNECT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (12) // #line 47 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.CONNECTOR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (13) // #line 48 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.CONSTANT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (14) // #line 49 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.DISCRETE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (15) // #line 50 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.DER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (16) // #line 51 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.DEFINEUNIT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (17) // #line 52 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EACH,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (18) // #line 53 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ELSE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (19) // #line 54 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ELSEIF,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (20) // #line 55 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ELSEWHEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (21) // #line 56 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.END,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (22) // #line 57 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ENUMERATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (23) // #line 58 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EQUATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (24) // #line 59 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ENCAPSULATED,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (25) // #line 60 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EXPANDABLE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (26) // #line 61 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EXTENDS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (27) // #line 62 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.CONSTRAINEDBY,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (28) // #line 63 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EXTERNAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (29) // #line 64 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.FALSE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (30) // #line 65 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.FINAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (31) // #line 66 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.FLOW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (32) // #line 67 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.FOR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (33) // #line 68 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.FUNCTION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (34) // #line 69 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.IF,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (35) // #line 70 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.IMPORT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (36) // #line 71 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.IN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (37) // #line 72 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.INITIAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (38) // #line 73 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.INNER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (39) // #line 74 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.INPUT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (40) // #line 75 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LOOP,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (41) // #line 76 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.MODEL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (42) // #line 77 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.NOT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (43) // #line 78 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.OUTER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (44) // #line 79 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.OPERATOR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (45) // #line 80 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.OVERLOAD,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (46) // #line 81 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.OR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (47) // #line 82 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.OUTPUT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (48) // #line 83 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PACKAGE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (49) // #line 84 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PARAMETER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (50) // #line 85 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PARTIAL,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (51) // #line 86 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PROTECTED,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (52) // #line 87 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PUBLIC,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (53) // #line 88 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.RECORD,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (54) // #line 89 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.REDECLARE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (55) // #line 90 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.REPLACEABLE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (56) // #line 91 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.THEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (57) // #line 92 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.TRUE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (58) // #line 93 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.TYPE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (59) // #line 94 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.WHEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (60) // #line 95 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.WHILE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (61) // #line 96 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.WITHIN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (62) // #line 97 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.RETURN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (63) // #line 98 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.BREAK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (64) // #line 100 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LPAR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (65) // #line 101 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.RPAR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (66) // #line 102 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LBRACK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (67) // #line 103 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.RBRACK,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (68) // #line 104 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LBRACE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (69) // #line 105 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.RBRACE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (70) // #line 106 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EQEQ,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (71) // #line 107 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.EQUALS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (72) // #line 108 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.COMMA,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (73) // #line 109 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.ASSIGN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (74) // #line 110 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.COLONCOLON,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (75) // #line 111 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.COLON,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (76) // #line 112 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.SEMICOLON,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (77) // #line 114 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PURE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (78) // #line 115 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.IMPURE,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (79) // #line 116 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.OPTIMIZATION,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (80) // #line 118 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PLUS_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (81) // #line 119 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.MINUS_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (82) // #line 120 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.STAR_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (83) // #line 121 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.SLASH_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (84) // #line 122 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.POWER_EW,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (85) // #line 124 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.STAR,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (86) // #line 125 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.MINUS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (87) // #line 126 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.PLUS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (88) // #line 127 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LESSEQ,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (89) // #line 128 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LESSGT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (90) // #line 129 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.LESS,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (91) // #line 130 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.GREATER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (92) // #line 131 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.GREATEREQ,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (93) // #line 133 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.POWER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (94) // #line 134 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.SLASH,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (95) // #line 136 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.SUBTYPEOF,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (96) // #line 138 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.STREAM,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (97) // #line 140 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.DOT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (98) // #line 142 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.IDENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (99) // #line 144 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.IDENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (100) // #line 146 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId.UNSIGNED_INTEGER,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (101) // #line 148 "lexerModelicaDiff.l"
algorithm
mm_startSt := 7;
bufferRet := buffer;
then noToken;
case (102) // #line 153 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (103) // #line 154 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (104) // #line 155 "lexerModelicaDiff.l"
algorithm
mm_startSt := 1;
tok := TOKEN(fileNm,TokenId.STRING,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (105) // #line 156 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (106) // #line 157 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (107) // #line 160 "lexerModelicaDiff.l"
algorithm
mm_startSt := 3;
bufferRet := buffer;
then noToken;
case (108) // #line 165 "lexerModelicaDiff.l"
algorithm
mm_startSt := 1;
tok := TOKEN(fileNm,TokenId.BLOCK_COMMENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (109) // #line 166 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (110) // #line 167 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (111) // #line 174 "lexerModelicaDiff.l"
algorithm
mm_startSt := 5;
bufferRet := buffer;
then noToken;
case (112) // #line 180 "lexerModelicaDiff.l"
algorithm
mm_startSt := 1;
tok := TOKEN(fileNm,TokenId.LINE_COMMENT,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
then tok;
case (113) // #line 181 "lexerModelicaDiff.l"
algorithm
bufferRet := buffer;
then noToken;
case (114) // #line 184 "lexerModelicaDiff.l"
algorithm
tok := TOKEN(fileNm,TokenId._NO_TOKEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
errorTokens := tok :: errorTokens;
then noToken;
else
algorithm
print("\nLexer unknown rule, action="+String(act)+"\n");
tok := TOKEN(fileNm,TokenId._NO_TOKEN,fileContents,mm_pos-buffer,buffer,lineNrStart,mm_ePos+1,mm_linenr,mm_sPos+1);
print(printToken(tok));
then fail();
end match;
end action;
type TokenId = enumeration(
_NO_TOKEN,
ALGORITHM,
AND,
ANNOTATION,
ASSIGN,
BLOCK,
BLOCK_COMMENT,
BREAK,
CLASS,
COLON,
COLONCOLON,
COMMA,
CONNECT,
CONNECTOR,
CONSTANT,
CONSTRAINEDBY,
DEFINEUNIT,
DER,
DISCRETE,
DOT,
EACH,
ELSE,
ELSEIF,
ELSEWHEN,
ENCAPSULATED,
END,
ENUMERATION,
EQEQ,
EQUALS,
EQUATION,
EXPANDABLE,
EXTENDS,
EXTERNAL,
FALSE,
FINAL,
FLOW,
FOR,
FUNCTION,
GREATER,
GREATEREQ,
IDENT,
IF,
IMPORT,
IMPURE,
IN,
INITIAL,
INNER,
INPUT,
LBRACE,
LBRACK,
LESS,
LESSEQ,
LESSGT,
LINE_COMMENT,
LOOP,
LPAR,
MINUS,
MINUS_EW,
MODEL,
MODELICA,
NEWLINE,
NOT,
OPERATOR,
OPTIMIZATION,
OR,
OUTER,
OUTPUT,
OVERLOAD,
PACKAGE,
PARAMETER,
PARTIAL,
PLUS,
PLUS_EW,
POWER,
POWER_EW,
PROTECTED,
PUBLIC,
PURE,
RBRACE,
RBRACK,
RECORD,
REDECLARE,
REPLACEABLE,
RETURN,
RPAR,
SEMICOLON,
SLASH,
SLASH_EW,
STAR,
STAR_EW,
STREAM,
STRING,
SUBTYPEOF,
THEN,
TRUE,
TYPE,
UNSIGNED_INTEGER,
UNSIGNED_REAL,
WHEN,
WHILE,
WHITESPACE,
WITHIN
);
uniontype Token
record TOKEN
String fileName;
TokenId id;
String fileContents;
Integer byteOffset,length;
Integer lineNumberStart;
Integer columnNumberStart;
Integer lineNumberEnd;
Integer columnNumberEnd;
end TOKEN;
end Token;
constant Token noToken = TOKEN("<NoFile>",TokenId._NO_TOKEN,"",0,0,0,0,0,0);
function printToken
input Token token;
output String strTk;
protected
TokenId id;
String contents;
Integer byteOffset,length;
algorithm
TOKEN(id=id, fileContents=contents, byteOffset=byteOffset, length=length) := token;
contents := if length>0 then substring(contents,byteOffset,byteOffset+length-1) else "";
strTk := "[TOKEN:" + String(id) + " '" + contents +"' (" + intString(token.lineNumberStart) + ":" + intString(token.columnNumberStart) + "-"+ intString(token.lineNumberEnd) + ":" + intString(token.columnNumberEnd) +")]";
end printToken;
function tokenContent
input Token token;
output String contents;
protected
Integer byteOffset,length;
algorithm
TOKEN(fileContents=contents,byteOffset=byteOffset,length=length) := token;
contents := if length>0 then substring(contents,byteOffset,byteOffset+length-1) else "";
end tokenContent;
function tokenContentEq
input Token token1, token2;
output Boolean b;
protected
String contents1,contents2;
Integer offset1,length1,offset2,length2;
algorithm
TOKEN(fileContents=contents1,byteOffset=offset1,length=length1) := token1;
TOKEN(fileContents=contents2,byteOffset=offset2,length=length2) := token2;
// We do not need to know in which order to sort. If lengths differ, the tokens differ
b := if length1 <> length2 then false else (0 == System.strcmp_offset(contents1, offset1, length1, contents2, offset2, length2));
end tokenContentEq;
function tokenSourceInfo
input Token token;
output SourceInfo info;
algorithm
info := match t as token
case TOKEN() then SOURCEINFO(t.fileName, false, t.lineNumberStart, t.columnNumberStart, t.lineNumberEnd, t.columnNumberEnd, 0.0);
end match;
end tokenSourceInfo;
protected
function lex "Scan starts the lexical analysis, load the tables and consume the program to output the tokens"
input String fileName "input source code file";
input String contents;
output list<Token> tokens "return list of tokens";
output list<Token> errorTokens={};
protected
Integer startSt,i,r,cTok,cTok2,currSt,pos,sPos,ePos,linenr,contentLen,numBacktrack,buffer,lineNrStart;
list<Integer> cProg,cProg2;
list<String> chars;
list<Integer> states;
String s1,s2;
import MetaModelica.Dangerous.listReverseInPlace;
import stringGet = MetaModelica.Dangerous.stringGetNoBoundsChecking;
algorithm
// load arrays
// Initialize the Env Variables
startSt := 1;
currSt := 1;
pos := 1;
sPos := 0;
ePos := 0;
linenr := 1;
lineNrStart := 1;
buffer := 0;
states := {};
if (debug==true) then
print("\nLexer analyzer LexerCode..." + fileName + "\n");
//printAny("\nLexer analyzer LexerCode..." + fileName + "\n");
end if;
tokens := {};
if (debug) then
print("\n TOTAL Chars:");
print(intString(stringLength(contents)));
end if;
contentLen := stringLength(contents);
i := 1;
while i <= contentLen loop
cTok := stringGet(contents,i);
(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);
i := i - numBacktrack + 1;
end while;
tokens := listReverseInPlace(tokens);
errorTokens := listReverseInPlace(errorTokens);
end lex;
function consume
input Integer cp;
input list<Token> tokens;
input String fileContents;
input Integer startSt;
input Integer currSt,pos,sPos,ePos,linenr,inLineNrStart;
input Integer inBuffer;
input list<Integer> inStates;
input String fileName;
input list<Token> inErrorTokens;
output list<Token> resToken;
output Integer bkBuffer = 0;
output Integer mm_startSt;
output Integer mm_currSt,mm_pos,mm_sPos,mm_ePos,mm_linenr,lineNrStart;
output Integer buffer;
output list<Integer> states;
output list<Token> errorTokens=inErrorTokens;
protected
Token tok;
Integer act,buffer2;
Integer c,baseCond;
algorithm
mm_startSt := startSt;
mm_currSt := currSt;
mm_pos := pos;
mm_sPos := sPos;
mm_ePos := ePos;
mm_linenr := linenr;
lineNrStart := inLineNrStart;
buffer := inBuffer;
states := inStates;
baseCond := LexTable.yy_base[mm_currSt];
if (debug==true) then
print("\nPROGRAM:{" + intString(cp) + "} ");
print("\nBUFFER:{" + intString(buffer) + "} ");
print("base:" + intString(baseCond) + " st:" + intString(mm_currSt)+" ");
end if;
buffer := buffer+1;
mm_pos := mm_pos+1;
if (cp==10) then
mm_linenr := mm_linenr+1;
mm_sPos := 0;
else
mm_sPos := mm_sPos+1;
end if;
if (debug==true) then
print("\n[Reading:'" + intStringChar(cp) +"' at p:" + intString(mm_pos-1) + " line:"+ intString(mm_linenr) + " rPos:" + intString(mm_sPos) +"]");
end if;
c := LexTable.yy_ec[cp];
if (debug==true) then
print(" evalState Before[c" + intString(c) + ",s"+ intString(mm_currSt)+"]");
end if;
(mm_currSt,c) := evalState(mm_currSt,c);
if (debug==true) then
print(" After[c" + intString(c) + ",s"+ intString(mm_currSt)+"]");
end if;
if (mm_currSt>0) then
mm_currSt := LexTable.yy_base[mm_currSt];
// print("BASE:"+ intString(mm_currSt)+"]");
mm_currSt := LexTable.yy_nxt[mm_currSt + c];
// print("NEXT:"+ intString(mm_currSt)+"]");
else
mm_currSt := LexTable.yy_nxt[c];
end if;
states := mm_currSt::states;
baseCond := LexTable.yy_base[mm_currSt];
if (baseCond==LexTable.yy_finish) then
if (debug==true) then
print("\n[RESTORE=" + intString(LexTable.yy_accept[mm_currSt]) + "]");
end if;
(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);
if (debug==true) then
print("\nFound rule: " + String(act));
end if;
(tok,mm_startSt,buffer2,errorTokens) := action(act,mm_startSt,mm_currSt,mm_pos,mm_sPos,mm_ePos,mm_linenr,lineNrStart,buffer,debug,fileName,fileContents,errorTokens);
if (debug==true) then
print("\nDid action");
end if;
mm_currSt := mm_startSt;
states := {};
/* Either a token was output (get new positions for next token). Or a whitespace was emitted. */
if buffer <> buffer2 then
mm_ePos := mm_sPos;
lineNrStart := linenr;
end if;
buffer := buffer2;
resToken := match tok
case TOKEN(id=TokenId._NO_TOKEN) then tokens;
else tok::tokens;
end match;
if(debug) then
print("\n CountTokens:" + intString(listLength(resToken)));
end if;
else
bkBuffer := 0; // consume the character
resToken := tokens;
end if;
end consume;
function findRule
input String fileContents;
input Integer currSt;
input Integer pos;
input Integer sPos;
input Integer mm_ePos;
input Integer linenr;
input Integer inBuffer;
input Integer inBkBuffer;
input list<Integer> inStates;
output Integer action;
output Integer mm_currSt;
output Integer mm_pos;
output Integer mm_sPos;
output Integer mm_linenr;
output Integer buffer;
output Integer bkBuffer;
output list<Integer> states;
protected
array<Integer> mm_accept,mm_ec,mm_meta,mm_base,mm_def,mm_nxt,mm_chk,mm_acclist;
Integer lp,lp1,stCmp,cp;
Boolean st;
import arrayGet = MetaModelica.Dangerous.arrayGetNoBoundsChecking; // Bounds checked with debug=true
import stringGet = MetaModelica.Dangerous.stringGetNoBoundsChecking;
algorithm
mm_currSt := currSt;
mm_pos := pos;
mm_sPos := sPos;
mm_linenr := linenr;
buffer := inBuffer;
bkBuffer := inBkBuffer;
states := inStates;
stCmp := listGet(states, 1);
lp := LexTable.yy_accept[stCmp];
lp1 := LexTable.yy_accept[stCmp+1];
st := intGt(lp,0) and intLt(lp,lp1);
if st then
if debug then
checkArrayModelica(LexTable.yy_accept,stCmp,sourceInfo());
checkArrayModelica(LexTable.yy_acclist,lp,sourceInfo());
end if;
lp := LexTable.yy_accept[stCmp];
action := LexTable.yy_acclist[lp];
else
cp := stringGet(fileContents,mm_pos-1);
buffer := buffer-1;
bkBuffer := bkBuffer+1;
mm_pos := mm_pos - 1;
mm_sPos := mm_sPos -1;
if (cp==10) then
mm_sPos := mm_ePos;
mm_linenr := mm_linenr-1;
end if;
mm_currSt::states := states;
(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);
end if;
end findRule;
function evalState
input Integer cState;
input Integer c;
output Integer new_state;
output Integer new_c;
protected
Integer cState1=cState;
Integer c1=c;
Integer val,val2,chk;
algorithm
chk := LexTable.yy_base[cState1];
chk := chk + c1;
val := LexTable.yy_chk[chk];
val2 := LexTable.yy_base[cState1] + c1;
if cState1<>val then
cState1 := LexTable.yy_def[cState1];
if cState1 >= LexTable.yy_limit then
c1 := LexTable.yy_meta[c1];
end if;
if (cState1>0) then
(cState1,c1) := evalState(cState1,c1);
end if;
end if;
new_state := cState1;
new_c := c1;
end evalState;
function checkArray<T>
input array<T> arr;
input Integer index;
input SourceInfo info;
protected
String filename;
Integer lineStart;
algorithm
if index<1 or index>arrayLength(arr) then
SOURCEINFO(fileName=filename, lineNumberStart=lineStart) := info;
print("\n[" + filename + ":" + String(lineStart) + "]: checkArray failed: arrayLength="+String(arrayLength(arr))+" index=" + String(index) + "\n");
fail();
end if;
end checkArray;
function checkArrayModelica
input Integer arr[:];
input Integer index;
input SourceInfo info;
protected
String filename;
Integer lineStart;
algorithm
if index<1 or index>size(arr,1) then
SOURCEINFO(fileName=filename, lineNumberStart=lineStart) := info;
print("\n[" + filename + ":" + String(lineStart) + "]: checkArray failed: arrayLength="+String(size(arr,1))+" index=" + String(index) + "\n");
fail();
end if;
end checkArrayModelica;
package LexTable