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"
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;

View file

@ -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++;