Made acceptable for flex (no yylineno, no yymorfl)

This commit is contained in:
ceriel 1991-01-11 14:35:14 +00:00
parent 818d2f10cf
commit 6acdb3e358
2 changed files with 24 additions and 12 deletions

View file

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

View file

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