ec4cab05b3804d3c204407e28dcbb2eff1ccea22
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <stdarg.h>
4 #include <ctype.h>
5 #include <string.h>
12 IDENT,
13 MODULE,
14 SEMICOLON,
15 END,
16 DOT,
17 VAR,
18 COLON,
19 BEGIN,
20 ASSIGN,
21 INTEGER,
22 TRUE,
23 FALSE,
24 LPAREN,
25 RPAREN,
26 EQUAL,
27 NEQ,
28 LESS,
29 LEQ,
30 GREAT,
31 GEQ,
32 PLUS,
33 MINUS,
34 OR,
35 STAR,
36 SLASH,
37 DIV,
38 MOD,
39 AND,
40 NOT
41 };
43 // =======================================================================
44 // UTILS
45 // =======================================================================
47 void
49 {
60 }
62 /*
63 static int
64 oberon_item_to_type_class(oberon_context_t * ctx, oberon_item_t * item)
65 {
66 int class;
68 switch(item -> mode)
69 {
70 case MODE_INTEGER:
71 class = OBERON_TYPE_INTEGER;
72 break;
73 case MODE_BOOLEAN:
74 class = OBERON_TYPE_BOOLEAN;
75 break;
76 case MODE_VAR:
77 class = item -> var -> type -> class;
78 break;
79 default:
80 oberon_error(ctx, "oberon_item_to_type_class: wat");
81 break;
82 }
84 return class;
85 }
86 */
88 /*
89 static void
90 oberon_autocast_to(oberon_context_t * ctx, oberon_item_t * from, oberon_item_t * to)
91 {
92 int from_class = oberon_item_to_type_class(ctx, from);
93 int to_class = oberon_item_to_type_class(ctx, to);
95 if(from_class != to_class)
96 {
97 oberon_error(ctx, "oberon_autocast_to: types not matched %i -> %i", from_class, to_class);
98 }
99 }
100 */
102 // =======================================================================
103 // TABLE
104 // =======================================================================
108 {
111 {
113 }
116 }
120 {
123 {
125 }
128 }
130 static void
132 {
135 {
137 }
140 {
142 }
151 }
153 // =======================================================================
154 // SCANER
155 // =======================================================================
157 static void
159 {
162 }
164 static void
166 {
170 }
172 static void
174 {
180 {
184 }
196 {
198 }
200 {
202 }
204 {
206 }
208 {
210 }
212 {
214 }
216 {
218 }
220 {
222 }
224 {
226 }
228 {
230 }
231 }
233 static void
235 {
241 {
245 }
256 }
258 static void
260 {
262 {
264 }
265 }
267 static void
269 {
272 {
284 {
287 }
313 {
316 }
322 {
325 }
354 }
355 }
357 static void
359 {
364 {
366 }
368 {
370 }
371 else
372 {
374 }
375 }
377 // =======================================================================
378 // EXPRESSION
379 // =======================================================================
387 oberon_new_operator(int op, oberon_type_t * result, oberon_expr_t * left, oberon_expr_t * right)
388 {
400 }
404 {
414 }
418 {
420 }
424 {
430 {
435 {
437 }
468 }
471 }
475 {
482 {
484 }
486 {
488 }
490 {
492 }
494 {
496 }
498 {
500 }
501 else
502 {
504 }
507 }
509 #define ISMULOP(x) \
510 ((x) >= STAR && (x) <= AND)
514 {
519 {
525 }
528 }
532 {
539 {
541 }
543 {
545 }
547 {
549 }
550 else
551 {
553 }
556 }
560 {
562 }
564 #define ISADDOP(x) \
565 ((x) >= PLUS && (x) <= OR)
569 {
574 {
577 }
579 {
582 }
586 {
592 }
595 {
597 }
600 }
604 {
611 {
613 }
615 {
617 }
619 {
621 }
623 {
625 }
627 {
629 }
631 {
633 }
634 else
635 {
637 }
640 }
642 #define ISRELATION(x) \
643 ((x) >= EQUAL && (x) <= GEQ)
647 {
652 {
658 }
661 }
663 // =======================================================================
664 // PARSER
665 // =======================================================================
667 static void
669 {
671 {
673 }
674 }
676 static void
678 {
681 }
685 {
690 }
694 {
699 {
701 }
704 }
706 static void
708 {
713 }
715 static void
717 {
719 {
722 {
725 }
726 }
727 }
729 static void
731 {
732 // if(dst -> mode == MODE_INTEGER)
733 // {
734 // oberon_error(ctx, "invalid assignment");
735 // }
736 //
737 // oberon_autocast_to(ctx, src, dst);
740 }
742 static void
744 {
749 {
754 }
755 }
757 static void
759 {
762 {
765 }
766 }
768 static void
770 {
782 {
787 }
794 {
796 }
797 }
799 // =======================================================================
800 // LIBRARY
801 // =======================================================================
805 {
808 {
810 }
813 {
815 }
817 // TODO: copy type name (not a pointer)
825 }
827 static void
829 {
835 }
837 void
839 {
841 }
843 oberon_context_t *
845 {
858 }
860 void
862 {
865 }
867 oberon_module_t *
869 {
882 }