On Monday 21 January 2008 02:12:36 Klaas-Jan Stol wrote:

> Not sure, but I don't think all '.const  .Sub foo = "foo" '  is gone
> already....
>
> before we rip out the dot stuff from IMCC, these should be rephrased.

Here's a patch to remove the dot stuff from IMCC.

Note that the parrot binary builds, but not everything else in 'make' does.  
It's finding errors for sure.

-- c

=== compilers/imcc/imcc.l
==================================================================
--- compilers/imcc/imcc.l	(revision 26603)
+++ compilers/imcc/imcc.l	(local)
@@ -520,20 +520,7 @@
 
 <emit,INITIAL>{DOT}{LETTER}{LETTERDIGIT}* {
         char   * const macro_name = yytext + 1;
-        STRING * name_string      = string_from_cstring(interp, macro_name, 0);
-        const int type            = pmc_type(interp, name_string);
 
-        if (type > 0) {
-            const size_t len = 16;
-            char * const buf = (char *)mem_sys_allocate(len);
-            snprintf(buf, len, "%d", type);
-
-            /* XXX: free valp->s if already used? Sounds like a good idea, */
-            /* but big segfaults if you do. */
-            valp->s = buf;
-            return INTC;
-        }
-
         if (!expand_macro(interp, macro_name, yyscanner)) {
             yyless(1);
             return DOT;
=== compilers/imcc/imclexer.c
==================================================================
--- compilers/imcc/imclexer.c	(revision 26603)
+++ compilers/imcc/imclexer.c	(local)
@@ -30,7 +30,7 @@
 #define FLEX_SCANNER
 #define YY_FLEX_MAJOR_VERSION 2
 #define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 34
+#define YY_FLEX_SUBMINOR_VERSION 33
 #if YY_FLEX_SUBMINOR_VERSION > 0
 #define FLEX_BETA
 #endif
@@ -52,7 +52,7 @@
 
 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
 
-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#if __STDC_VERSION__ >= 199901L
 
 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  * if you want the limit (max/min) macros for int types. 
@@ -115,12 +115,11 @@
 
 #else	/* ! __cplusplus */
 
-/* C99 requires __STDC__ to be defined as 1. */
-#if defined (__STDC__)
+#if __STDC__
 
 #define YY_USE_CONST
 
-#endif	/* defined (__STDC__) */
+#endif	/* __STDC__ */
 #endif	/* ! __cplusplus */
 
 #ifdef YY_USE_CONST
@@ -156,6 +155,8 @@
 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
 #define yy_flex_debug yyg->yy_flex_debug_r
 
+int yylex_init (yyscan_t* scanner);
+
 /* Enter a start condition.  This macro really ought to take a parameter,
  * but we do it the disgusting crufty way forced on us by the ()-less
  * definition of BEGIN.
@@ -216,13 +217,11 @@
 /* The following is because we cannot portably get our hands on size_t
  * (without autoconf's help, which isn't available because we want
  * flex-generated scanners to compile on their own).
- * Given that the standard has decreed that size_t exists since 1989,
- * I guess we can afford to depend on it. Manoj.
  */
 
 #ifndef YY_TYPEDEF_YY_SIZE_T
 #define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
+typedef unsigned int yy_size_t;
 #endif
 
 #ifndef YY_STRUCT_YY_BUFFER_STATE
@@ -2773,7 +2772,7 @@
 
 
 
-#line 2777 "compilers/imcc/imclexer.c"
+#line 2776 "compilers/imcc/imclexer.c"
 
 #define INITIAL 0
 #define emit 1
@@ -2835,10 +2834,6 @@
 
 static int yy_init_globals (yyscan_t yyscanner );
 
-int yylex_init (yyscan_t* scanner);
-
-int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
-
 /* Accessor methods to globals.
    These are made visible to non-reentrant scanners for convenience. */
 
@@ -2916,7 +2911,7 @@
 /* This used to be an fputs(), but since the string might contain NUL's,
  * we now use fwrite().
  */
-#define ECHO fwrite( yytext, yyleng, 1, yyout )
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
 #endif
 
 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
@@ -2927,7 +2922,7 @@
 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
 		{ \
 		int c = '*'; \
-		int n; \
+		size_t n; \
 		for ( n = 0; n < max_size && \
 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
 			buf[n] = (char) c; \
@@ -3032,7 +3027,7 @@
             return 0;
         }
 
-#line 3036 "compilers/imcc/imclexer.c"
+#line 3031 "compilers/imcc/imclexer.c"
 
 	if ( !yyg->yy_init )
 		{
@@ -3893,20 +3888,7 @@
 #line 521 "compilers/imcc/imcc.l"
 {
         char   * const macro_name = yytext + 1;
-        STRING * name_string      = string_from_cstring(interp, macro_name, 0);
-        const int type            = pmc_type(interp, name_string);
 
-        if (type > 0) {
-            const size_t len = 16;
-            char * const buf = (char *)mem_sys_allocate(len);
-            snprintf(buf, len, "%d", type);
-
-            /* XXX: free valp->s if already used? Sounds like a good idea, */
-            /* but big segfaults if you do. */
-            valp->s = buf;
-            return INTC;
-        }
-
         if (!expand_macro(interp, macro_name, yyscanner)) {
             yyless(1);
             return DOT;
@@ -3915,7 +3897,7 @@
 	YY_BREAK
 case 118:
 YY_RULE_SETUP
-#line 543 "compilers/imcc/imcc.l"
+#line 530 "compilers/imcc/imcc.l"
 {
         if (!is_def) {
             SymReg *r = find_sym(interp, yytext);
@@ -3945,32 +3927,32 @@
 	YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 570 "compilers/imcc/imcc.l"
+#line 557 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, FLOATC);
 	YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 571 "compilers/imcc/imcc.l"
+#line 558 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 121:
 YY_RULE_SETUP
-#line 572 "compilers/imcc/imcc.l"
+#line 559 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 573 "compilers/imcc/imcc.l"
+#line 560 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 574 "compilers/imcc/imcc.l"
+#line 561 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, INTC);
 	YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 576 "compilers/imcc/imcc.l"
+#line 563 "compilers/imcc/imcc.l"
 {
         valp->s = str_dup(yytext);
 
@@ -3983,7 +3965,7 @@
 	YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 586 "compilers/imcc/imcc.l"
+#line 573 "compilers/imcc/imcc.l"
 {
         valp->s = str_dup(yytext);
 
@@ -3993,7 +3975,7 @@
 	YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 593 "compilers/imcc/imcc.l"
+#line 580 "compilers/imcc/imcc.l"
 {
         macro_frame_t *frame;
 
@@ -4025,7 +4007,7 @@
 	YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 622 "compilers/imcc/imcc.l"
+#line 609 "compilers/imcc/imcc.l"
 {
         /* charset:"..." */
         valp->s = str_dup(yytext);
@@ -4036,7 +4018,7 @@
 	YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 630 "compilers/imcc/imcc.l"
+#line 617 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return IREG;
@@ -4044,7 +4026,7 @@
 	YY_BREAK
 case 129:
 YY_RULE_SETUP
-#line 635 "compilers/imcc/imcc.l"
+#line 622 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return NREG;
@@ -4052,7 +4034,7 @@
 	YY_BREAK
 case 130:
 YY_RULE_SETUP
-#line 640 "compilers/imcc/imcc.l"
+#line 627 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return SREG;
@@ -4060,7 +4042,7 @@
 	YY_BREAK
 case 131:
 YY_RULE_SETUP
-#line 645 "compilers/imcc/imcc.l"
+#line 632 "compilers/imcc/imcc.l"
 {
         if (valp) (valp)->s = yytext;
         return PREG;
@@ -4068,7 +4050,7 @@
 	YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 650 "compilers/imcc/imcc.l"
+#line 637 "compilers/imcc/imcc.l"
 {
         IMCC_fataly(interp, E_SyntaxError,
             "'%s' is not a valid register name", yytext);
@@ -4076,19 +4058,19 @@
 	YY_BREAK
 case 133:
 YY_RULE_SETUP
-#line 656 "compilers/imcc/imcc.l"
+#line 643 "compilers/imcc/imcc.l"
 /* skip */;
 	YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 658 "compilers/imcc/imcc.l"
+#line 645 "compilers/imcc/imcc.l"
 {
         /* catch all except for state macro */
         return yytext[0];
     }
 	YY_BREAK
 case YY_STATE_EOF(emit):
-#line 663 "compilers/imcc/imcc.l"
+#line 650 "compilers/imcc/imcc.l"
 {
         BEGIN(INITIAL);
 
@@ -4101,18 +4083,18 @@
     }
 	YY_BREAK
 case YY_STATE_EOF(INITIAL):
-#line 674 "compilers/imcc/imcc.l"
+#line 661 "compilers/imcc/imcc.l"
 yyterminate();
 	YY_BREAK
 case 135:
 YY_RULE_SETUP
-#line 676 "compilers/imcc/imcc.l"
+#line 663 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, ENDM);
 	YY_BREAK
 case 136:
 /* rule 136 can match eol */
 YY_RULE_SETUP
-#line 678 "compilers/imcc/imcc.l"
+#line 665 "compilers/imcc/imcc.l"
 {
         IMCC_INFO(interp)->line++;
         DUP_AND_RET(valp, '\n');
@@ -4120,12 +4102,12 @@
 	YY_BREAK
 case 137:
 YY_RULE_SETUP
-#line 683 "compilers/imcc/imcc.l"
+#line 670 "compilers/imcc/imcc.l"
 return LABEL;
 	YY_BREAK
 case 138:
 YY_RULE_SETUP
-#line 685 "compilers/imcc/imcc.l"
+#line 672 "compilers/imcc/imcc.l"
 {
 
         if (yylex(valp,yyscanner,interp) != LABEL)
@@ -4151,7 +4133,7 @@
 	YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 708 "compilers/imcc/imcc.l"
+#line 695 "compilers/imcc/imcc.l"
 {
         if (valp) {
             const size_t len = strlen(IMCC_INFO(interp)->cur_macro_name) + yyleng + 12;
@@ -4168,39 +4150,39 @@
 	YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 722 "compilers/imcc/imcc.l"
+#line 709 "compilers/imcc/imcc.l"
 /* skip leading ws */;
 	YY_BREAK
 case 141:
 YY_RULE_SETUP
-#line 723 "compilers/imcc/imcc.l"
+#line 710 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, ' ');
 	YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 724 "compilers/imcc/imcc.l"
+#line 711 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, IDENTIFIER);
 	YY_BREAK
 case 143:
 YY_RULE_SETUP
-#line 725 "compilers/imcc/imcc.l"
+#line 712 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, MACRO);
 	YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 726 "compilers/imcc/imcc.l"
+#line 713 "compilers/imcc/imcc.l"
 DUP_AND_RET(valp, yytext[0]);
 	YY_BREAK
 case YY_STATE_EOF(macro):
-#line 727 "compilers/imcc/imcc.l"
+#line 714 "compilers/imcc/imcc.l"
 yyterminate();
 	YY_BREAK
 case 145:
 YY_RULE_SETUP
-#line 729 "compilers/imcc/imcc.l"
+#line 716 "compilers/imcc/imcc.l"
 ECHO;
 	YY_BREAK
-#line 4204 "compilers/imcc/imclexer.c"
+#line 4186 "compilers/imcc/imclexer.c"
 case YY_STATE_EOF(pod):
 case YY_STATE_EOF(cmt1):
 case YY_STATE_EOF(cmt2):
@@ -4464,14 +4446,6 @@
 	else
 		ret_val = EOB_ACT_CONTINUE_SCAN;
 
-	if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
-		/* Extend the array by 50%, plus the number we really need. */
-		yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
-		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
-		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
-			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
-	}
-
 	yyg->yy_n_chars += number_to_move;
 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
 	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
@@ -4899,9 +4873,7 @@
 		yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
 								(num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
-		if ( ! yyg->yy_buffer_stack )
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
-								  
+		
 		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
 				
 		yyg->yy_buffer_stack_max = num_to_alloc;
@@ -4919,8 +4891,6 @@
 								(yyg->yy_buffer_stack,
 								num_to_alloc * sizeof(struct yy_buffer_state*)
 								, yyscanner);
-		if ( ! yyg->yy_buffer_stack )
-			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
 
 		/* zero only the new slots.*/
 		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
@@ -5031,7 +5001,8 @@
 			yyg->yy_start_stack = (int *) yyrealloc((void *) yyg->yy_start_stack,new_size ,yyscanner );
 
 		if ( ! yyg->yy_start_stack )
-			YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
+			YY_FATAL_ERROR(
+			"out of memory expanding start-condition stack" );
 		}
 
 	yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;
@@ -5255,42 +5226,6 @@
     return yy_init_globals ( *ptr_yy_globals );
 }
 
-/* yylex_init_extra has the same functionality as yylex_init, but follows the
- * convention of taking the scanner as the last argument. Note however, that
- * this is a *pointer* to a scanner, as it will be allocated by this call (and
- * is the reason, too, why this function also must handle its own declaration).
- * The user defined value in the first argument will be available to yyalloc in
- * the yyextra field.
- */
-
-int yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
-
-{
-    struct yyguts_t dummy_yyguts;
-
-    yyset_extra (yy_user_defined, &dummy_yyguts);
-
-    if (ptr_yy_globals == NULL){
-        errno = EINVAL;
-        return 1;
-    }
-	
-    *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
-	
-    if (*ptr_yy_globals == NULL){
-        errno = ENOMEM;
-        return 1;
-    }
-    
-    /* By setting to 0xAA, we expose bugs in
-    yy_init_globals. Leave at 0x00 for releases. */
-    memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
-    
-    yyset_extra (yy_user_defined, *ptr_yy_globals);
-    
-    return yy_init_globals ( *ptr_yy_globals );
-}
-
 static int yy_init_globals (yyscan_t yyscanner)
 {
     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
@@ -5402,7 +5337,7 @@
 
 #define YYTABLES_NAME "yytables"
 
-#line 729 "compilers/imcc/imcc.l"
+#line 716 "compilers/imcc/imcc.l"
 
 
 

Reply via email to