From 6acdb3e358fb1500986dda323561b9f1b1934068 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 11 Jan 1991 14:35:14 +0000 Subject: [PATCH] Made acceptable for flex (no yylineno, no yymorfl) --- util/ceg/as_parser/pars.g | 30 ++++++++++++++++++++---------- util/ceg/as_parser/table.l | 6 ++++-- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/util/ceg/as_parser/pars.g b/util/ceg/as_parser/pars.g index 9b3348762..b61cc1ea0 100644 --- a/util/ceg/as_parser/pars.g +++ b/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; diff --git a/util/ceg/as_parser/table.l b/util/ceg/as_parser/table.l index 791949bd6..167fb358d 100644 --- a/util/ceg/as_parser/table.l +++ b/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; [^\n\*]*"*"+"/" BEGIN 0; [^\n^\*]*"*"+ ; -[^\n\*]*"\n" ; +[^\n\*]*"\n" lineno++; ";" return( ';'); "." return( '.'); @@ -50,3 +51,4 @@ int special, n_haakjes; } {ws} ; +\n lineno++;