changeset 20:8d3db5fc8a97

*** empty log message ***
author kono
date Mon, 03 Feb 2003 17:52:54 +0900
parents b62230ea38f6
children f9f789aa7587
files mc-parse.c mc.h stdio.h
diffstat 3 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mc-parse.c	Mon Feb 03 17:27:05 2003 +0900
+++ b/mc-parse.c	Mon Feb 03 17:52:54 2003 +0900
@@ -260,6 +260,7 @@
     reserve("int",INT);
     reserve("void",VOID);
     reserve("char",CHAR);
+    reserve("const",KONST);
     reserve("struct",STRUCT);
     reserve("union",UNION);
     reserve("unsigned",UNSIGNED);
@@ -404,6 +405,9 @@
 {
     int t;
 
+    while (sym==KONST) {
+	getsym();
+    }
     switch(sym) {
     case VOID:
     case INT:
@@ -440,9 +444,15 @@
 		break;
 	    }
 	}
+	while (sym==KONST) {
+	    getsym();
+	}
 	if(mode==LDECL) return 0;
 	t= INT;
     }
+    while (sym==KONST) {
+	getsym();
+    }
     return t;
 }
 
@@ -1709,7 +1719,7 @@
     case LNOT:
 	getsym();
 	e=rvalue(expr13());
-	if(!integral(type)) 
+	if(!scalar(type)) 
 	    error(TYERR);
 	return(car(e)==CONST?list2(CONST,!cadr(e)):list2(LNOT,e));
     case SIZEOF:
@@ -2156,6 +2166,8 @@
     return (cadr(e));
 }
 
+int in_comment = 0;
+
 int
 getsym(void)
 {
@@ -2304,8 +2316,10 @@
 	    return sym=PERIOD;
     case '/':
 	if(ch!='*') return postequ(DIV,DIV+AS);
+	in_comment = 1;
 	getch();
 	while(ch=='*'?getch()!='/':getch());
+	in_comment = 0;
 	getch();
 	return getsym();
     default:
@@ -2510,7 +2524,7 @@
 	}
 	*chptr = '\0';
 	if (lsrc && !asmf) gen_comment(linebuf);
-	if (*(chptr = linebuf) == '#') {	
+	if (*(chptr = linebuf) == '#' && !in_comment) {	
 	    macro_processing();
 	}
     } while(macro_if_skip);
@@ -2535,7 +2549,6 @@
 	    macro_if_depth = macro_if_current;
 	    macro_if_skip = (!i)^c;
 	}
-fprintf(stderr,"macro ifdef %d %d %d %d %s\n",macro_if_skip,macro_if_current,macro_if_depth,lineno,linebuf);
 	return;
     } else if (macroeq("if")) {	
 	macro_if_current++;
@@ -2546,7 +2559,6 @@
 	    macro_if_depth = macro_if_current;
 	    macro_if_skip = !i;
 	}
-fprintf(stderr,"macro if    %d %d %d %d %s\n",macro_if_skip,macro_if_current,macro_if_depth,lineno,linebuf);
 	return;
     } else if (macroeq("else")) {	
 	if (macro_if_current==0) {
@@ -2555,7 +2567,6 @@
 	}
 	if (macro_if_current == macro_if_depth) 
 	    macro_if_skip = !macro_if_skip;
-fprintf(stderr,"macro else  %d %d %d %d %s\n",macro_if_skip,macro_if_current,macro_if_depth,lineno,linebuf);
 	return;
     } else if (macroeq("endif")) {	
 	if (macro_if_current == macro_if_depth) {
@@ -2568,7 +2579,6 @@
 	    }
 	    macro_if_current--;
 	}
-fprintf(stderr,"macro endif %d %d %d %d %s\n",macro_if_skip,macro_if_current,macro_if_depth,lineno,linebuf);
 	return;
     }
     if (macro_if_skip) return;
--- a/mc.h	Mon Feb 03 17:27:05 2003 +0900
+++ b/mc.h	Mon Feb 03 17:52:54 2003 +0900
@@ -53,6 +53,7 @@
 #define CODE	(-39)
 #define ENVIRONMENT	(-40)
 #define DEFINED	(-41)
+#define KONST	(-42)
 
 #define TOP	0
 #define GDECL	1
--- a/stdio.h	Mon Feb 03 17:27:05 2003 +0900
+++ b/stdio.h	Mon Feb 03 17:52:54 2003 +0900
@@ -1,7 +1,3 @@
-#ifdef __micro_c__
-#define const
-#endif
-
 typedef	struct {
 	/* this is all wrong, but so what? */
 	char	pad[96];