Explorar el Código

Made acceptable for flex (no yylineno, no yymorfl)

ceriel hace 33 años
padre
commit
92229ee6bf
Se han modificado 2 ficheros con 24 adiciones y 12 borrados
  1. 20 10
      util/ceg/as_parser/pars.g
  2. 4 2
      util/ceg/as_parser/table.l

+ 20 - 10
util/ceg/as_parser/pars.g

@@ -40,8 +40,8 @@
 {
 
 #include "decl.h"
-extern int yylineno, yyleng, yymorfg;
-extern char yytext[];
+extern int lineno, yyleng;
+extern char *yytext;
 
 }
 
@@ -100,13 +100,23 @@ action		: if_statement
  * by '(' and ')'. CONDITION is a token that matches this construct;
  */
 
-subroutine	: IDENTIFIER		{ yymorfg=1;}
-		  CONDITION		{ pr_subroutine( yytext);}
+subroutine
+  { char *s; }	: IDENTIFIER		{ s = Salloc(yytext, yyleng+1); }
+		  CONDITION		{ s = Realloc(s, strlen(s)+yyleng+1);
+					  strcat(s, yytext);
+					  pr_subroutine( s);
+					  free(s);
+					}
 		;
 
-call		: '@'
-		  IDENTIFIER		{ yymorfg=1;}
-		  CONDITION		{ pr_call( yytext);}
+call
+  { char *s; }	: '@'
+		  IDENTIFIER		{ s = Salloc(yytext, yyleng+1); }
+		  CONDITION		{ s = Realloc(s, strlen(s)+yyleng+1);
+					  strcat(s, yytext);
+					  pr_call( s);
+					  free(s);
+					}
 		;
 
 if_statement	: IF
@@ -133,16 +143,16 @@ int inserted_token;
 {
 	nerrors++;
 	if ( inserted_token == 0) {
-		fprint( STDERR, "Sytax error in line %d, ", yylineno);
+		fprint( STDERR, "Sytax error in line %d, ", lineno);
 		print_token( LLsymb);
 		fprint( STDERR, "  will be deleted!!\n");
 	}
 	else if ( inserted_token < 0) {
 		fprint( STDERR, "Garbage at end, line %d!!\n",
-			 yylineno);
+			 lineno);
 	}
 	else {
-		fprint( STDERR, "Sytax error in line %d, ", yylineno);
+		fprint( STDERR, "Sytax error in line %d, ", lineno);
 		print_token( inserted_token);
 		fprint( STDERR, "  will be inserted!!\n");
 		token = LLsymb;

+ 4 - 2
util/ceg/as_parser/table.l

@@ -1,5 +1,5 @@
 
-ws		([ \t\n]*)
+ws		([ \t]*)
 arrow		("==>")
 letter		([a-zA-Z_])
 digit		([0-9])
@@ -12,6 +12,7 @@ identifier	({letter}({letter}|{digit})*)
 #include "Lpars.h"
 #include "decl.h"
 int special, n_haakjes;
+int lineno = 1;
 
 %}
 
@@ -21,7 +22,7 @@ int special, n_haakjes;
 "/*"			BEGIN COM;
 <COM>[^\n\*]*"*"+"/"	BEGIN 0;
 <COM>[^\n^\*]*"*"+	;
-<COM>[^\n\*]*"\n"	;
+<COM>[^\n\*]*"\n"	lineno++;
 
 ";"			return( ';');
 "."			return( '.');
@@ -50,3 +51,4 @@ int special, n_haakjes;
 			}
 
 {ws}			;
+\n			lineno++;