ppc: codea_abgabe_a{i,h} gehen jetzt auch, bin mir dabei aber ned ganz sicher...
[uebersetzerbau-ss10.git] / scanner / scanner.lex
index ebf5f8fc461b24c42cb1c60415e248d8a2bcbeab..07b162e1d3580e03ed393a3bc58e6c625447bc14 100644 (file)
@@ -3,7 +3,7 @@
        #include <string.h>
 
 KEYWORD struct|end|method|var|if|then|else|while|do|return|not|or|this
-SPECIAL_CHAR \;|\(|\)|\:=|\.|\-|\*|\<|\=|\.
+SPECIAL_CHAR \;|\(|\)|\:=|\.|\-|\*|\<|\=|\,
 IDENTIFIER [a-zA-Z_][0-9a-zA-Z_]*
 NUMBER_HEX 0x[0-9A-Fa-f]+
 NUMBER_DEC [0-9]+
@@ -20,9 +20,12 @@ COMMENT_END  \*\/
 
 <COMMENT>{COMMENT_END} BEGIN(INITIAL);
 
-<COMMENT><<EOF>> { (void) fprintf(stderr, "kommentar nicht geschlossen\n"); exit(1); }
+<COMMENT><<EOF>> {
+       fprintf(stderr, "Kommentar nicht geschlossen\n");
+       exit(1);
+}
 
-<COMMENT>. /* alles im kommentar wird ignoriert */
+<COMMENT>(.|\n) /* alles im kommentar wird ignoriert */
 
 {KEYWORD} printf("%s\n", yytext);
 
@@ -30,19 +33,16 @@ COMMENT_END \*\/
 
 {IDENTIFIER} printf("ident %s\n", yytext);
 
-{NUMBER_DEC} printf("num %x\n", strtol(yytext, (char **)NULL, 10));
+{NUMBER_DEC} printf("num %lx\n", strtol(yytext, (char **)NULL, 10));
 
-{NUMBER_HEX} {
-#if 0
-       char *copy=strdup(yytext);
-       copy[strlen(copy)-1]='\0';
-#endif
-       printf("num %x\n", strtol(yytext, (char **)NULL, 16));
-}
+{NUMBER_HEX} printf("num %lx\n", strtol(yytext, (char **)NULL, 16));
 
 {WHITESPACE} /* ignorieren */
 
-. { (void) fprintf(stderr, "Lexikalischer fehler auf Zeile %i\n", yylineno); exit(1); }
+. {
+       fprintf(stderr, "Lexikalischer Fehler auf Zeile %i\n", yylineno);
+       exit(1);
+}
 
 %%