Made acceptable for flex (no yylineno)

This commit is contained in:
ceriel 1991-01-11 14:32:43 +00:00
parent efa476b5b3
commit 818d2f10cf
4 changed files with 30 additions and 26 deletions

View file

@ -366,11 +366,11 @@ void rom(size, c) int size; long c;
void lin() void lin()
{ {
static oldline=0; static oldline=0;
extern yylineno; extern lineno;
if (Lflag) return; if (Lflag) return;
if (yylineno!=oldline) if (lineno!=oldline)
C_lin((arith) (oldline=yylineno)); C_lin((arith) (oldline=lineno));
} }
static struct ftree { static struct ftree {

View file

@ -22,6 +22,7 @@ int ind=0; /* Indentation level of current line */
static int tab=0; /* First indentation found */ static int tab=0; /* First indentation found */
int included=0; /* Is current file included? */ int included=0; /* Is current file included? */
int lineno = 1;
%} %}
%% %%
@ -76,10 +77,13 @@ int included=0; /* Is current file included? */
return key; return key;
} }
\n[ \f\t]*/"--" {/* Line with only a comment, don't set tab */} \n[ \f\t]*/"--" {/* Line with only a comment, don't set tab */
lineno++;
}
\n[ \f\t]* { \n[ \f\t]* {
lineno++;
ind=indentation(yytext+1); ind=indentation(yytext+1);
if (tab==0) if (tab==0)
tab=ind; tab=ind;
@ -332,11 +336,11 @@ set_line_file(l) register char *l;
while (*l<'0' || *l>'9') l++; while (*l<'0' || *l>'9') l++;
yylineno=0; lineno=0;
while ('0'<=*l && *l<='9') while ('0'<=*l && *l<='9')
yylineno=yylineno*10+(*l++ - '0'); lineno=lineno*10+(*l++ - '0');
yylineno--; lineno--;
while (*l++!='"'); while (*l++!='"');

View file

@ -19,7 +19,7 @@ static void nonconst(), nonpositive(), rep_cleanup(), check_assoc();
void init_builtins(); void init_builtins();
char *strcpy(); char *strcpy();
extern int yylineno, LLsymb; extern int lineno, LLsymb;
union type_info info, none; union type_info info, none;
} }
%token AFTER, ALLOCATE, ALT, AND, ANY, BYTE, CHAN, DEF, FALSE, FOR, IF, LOAD; %token AFTER, ALLOCATE, ALT, AND, ANY, BYTE, CHAN, DEF, FALSE, FOR, IF, LOAD;
@ -115,8 +115,8 @@ guarded_process(register *END;) { struct symbol *v;
guard(&F) process { branch(END); guard(&F) process { branch(END);
Label(F); Label(F);
} }
| ALT { line=yylineno; oind=ind; } | ALT { line=lineno; oind=ind; }
[ %if (line==yylineno) [ %if (line==lineno)
replicator(&v, &e1, &e2) replicator(&v, &e1, &e2)
{ rep_init(v, e1, e2, &to_test); } { rep_init(v, e1, e2, &to_test); }
guarded_process(END) guarded_process(END)
@ -144,8 +144,8 @@ conditional(register *END; ) { struct symbol *v;
{ branch(END); { branch(END);
Label(F); Label(F);
} }
| IF { line=yylineno; oind=ind; } | IF { line=lineno; oind=ind; }
[ %if (line==yylineno) [ %if (line==lineno)
replicator(&v, &e1, &e2) replicator(&v, &e1, &e2)
{ rep_init(v, e1, e2, &to_test); } { rep_init(v, e1, e2, &to_test); }
conditional(END) conditional(END)
@ -176,8 +176,8 @@ construct { struct symbol *v;
register line, oind; register line, oind;
int BEGIN=0, END=0, NONZERO; int BEGIN=0, END=0, NONZERO;
}: }:
SEQ { line=yylineno; oind=ind; } SEQ { line=lineno; oind=ind; }
[ %if (line==yylineno) [ %if (line==lineno)
replicator(&v, &e1, &e2) replicator(&v, &e1, &e2)
{ rep_init(v, e1, e2, &to_test); } { rep_init(v, e1, e2, &to_test); }
process process
@ -188,10 +188,10 @@ construct { struct symbol *v;
[ %while (tabulated(oind, ind)) process ]* [ %while (tabulated(oind, ind)) process ]*
] ]
| PRI ? | PRI ?
[ PAR { line=yylineno; oind=ind; [ PAR { line=lineno; oind=ind;
par_begin(); par_begin();
} }
[ %if (line==yylineno) [ %if (line==lineno)
replicator(&v, &e1, &e2) replicator(&v, &e1, &e2)
{ rep_init(v, e1, e2, &to_test); { rep_init(v, e1, e2, &to_test);
NONZERO=0; NONZERO=0;
@ -217,11 +217,11 @@ construct { struct symbol *v;
{ Label(END); { Label(END);
par_end(); par_end();
} }
| ALT { line=yylineno; oind=ind; | ALT { line=lineno; oind=ind;
no_deadlock(); no_deadlock();
Label(new_label(&BEGIN)); Label(new_label(&BEGIN));
} }
[ %if (line==yylineno) [ %if (line==lineno)
replicator(&v, &e1, &e2) replicator(&v, &e1, &e2)
{ rep_init(v, e1, e2, &to_test); } { rep_init(v, e1, e2, &to_test); }
guarded_process(&END) guarded_process(&END)
@ -237,8 +237,8 @@ construct { struct symbol *v;
Label(END); Label(END);
} }
] ]
| IF { line=yylineno; oind=ind; } | IF { line=lineno; oind=ind; }
[ %if (line==yylineno) [ %if (line==lineno)
replicator(&v, &e1, &e2) replicator(&v, &e1, &e2)
{ rep_init(v, e1, e2, &to_test); } { rep_init(v, e1, e2, &to_test); }
conditional(&END) conditional(&END)
@ -453,7 +453,7 @@ item(register struct expr **e;)
int byte, err=0, subs_call=0; int byte, err=0, subs_call=0;
struct expr_list *elp=nil, **aelp= &elp; struct expr_list *elp=nil, **aelp= &elp;
}: }:
IDENTIFIER { line=yylineno; IDENTIFIER { line=lineno;
oind=ind; oind=ind;
var=searchall(token.t_sval); var=searchall(token.t_sval);
@ -465,7 +465,7 @@ item(register struct expr **e;)
*e=new_var(var); *e=new_var(var);
} }
} }
[ %while (line==yylineno || tabulated(oind, ind)) [ %while (line==lineno || tabulated(oind, ind))
[ subscript(&byte, &e1) [ subscript(&byte, &e1)
{ *e=new_node('[', *e, e1, byte); } { *e=new_node('[', *e, e1, byte); }
| '(' { if (!var_declared(var)) { | '(' { if (!var_declared(var)) {

View file

@ -5,13 +5,13 @@
*/ */
#include <system.h> #include <system.h>
extern int err, yylineno; extern int err, lineno;
extern char *curr_file; extern char *curr_file;
/*VARARGS1*/ /*VARARGS1*/
report(fmt, arg1, arg2, arg3) char *fmt; report(fmt, arg1, arg2, arg3) char *fmt;
{ {
fprint(STDERR, "%s (%d) F: ", curr_file, yylineno); fprint(STDERR, "%s (%d) F: ", curr_file, lineno);
fprint(STDERR, fmt, arg1, arg2, arg3); fprint(STDERR, fmt, arg1, arg2, arg3);
fprint(STDERR,"\n"); fprint(STDERR,"\n");
err=1; err=1;
@ -20,7 +20,7 @@ report(fmt, arg1, arg2, arg3) char *fmt;
/*VARARGS1*/ /*VARARGS1*/
warning(fmt, arg1, arg2, arg3) char *fmt, *arg1; warning(fmt, arg1, arg2, arg3) char *fmt, *arg1;
{ {
fprint(STDERR, "%s (%d) E: ", curr_file, yylineno); fprint(STDERR, "%s (%d) E: ", curr_file, lineno);
fprint(STDERR, fmt, arg1, arg2, arg3); fprint(STDERR, fmt, arg1, arg2, arg3);
fprint(STDERR,"\n"); fprint(STDERR,"\n");
} }
@ -28,7 +28,7 @@ warning(fmt, arg1, arg2, arg3) char *fmt, *arg1;
/*VARARGS1*/ /*VARARGS1*/
fatal(fmt, arg1, arg2, arg3) char *fmt, *arg1; fatal(fmt, arg1, arg2, arg3) char *fmt, *arg1;
{ {
fprint(STDERR, "%s (%d) X: ", curr_file, yylineno); fprint(STDERR, "%s (%d) X: ", curr_file, lineno);
fprint(STDERR, fmt, arg1, arg2, arg3); fprint(STDERR, fmt, arg1, arg2, arg3);
fprint(STDERR,"\n"); fprint(STDERR,"\n");
exit(1); exit(1);