From 818d2f10cffde4b1c10c02cb818afa7ccbb671e1 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 11 Jan 1991 14:32:43 +0000 Subject: [PATCH] Made acceptable for flex (no yylineno) --- lang/occam/comp/em.c | 6 +++--- lang/occam/comp/lex.l | 12 ++++++++---- lang/occam/comp/occam.g | 30 +++++++++++++++--------------- lang/occam/comp/report.c | 8 ++++---- 4 files changed, 30 insertions(+), 26 deletions(-) diff --git a/lang/occam/comp/em.c b/lang/occam/comp/em.c index 8bb635bc7..47df1849e 100644 --- a/lang/occam/comp/em.c +++ b/lang/occam/comp/em.c @@ -366,11 +366,11 @@ void rom(size, c) int size; long c; void lin() { static oldline=0; - extern yylineno; + extern lineno; if (Lflag) return; - if (yylineno!=oldline) - C_lin((arith) (oldline=yylineno)); + if (lineno!=oldline) + C_lin((arith) (oldline=lineno)); } static struct ftree { diff --git a/lang/occam/comp/lex.l b/lang/occam/comp/lex.l index fdc19e890..ae6d6bde3 100644 --- a/lang/occam/comp/lex.l +++ b/lang/occam/comp/lex.l @@ -22,6 +22,7 @@ int ind=0; /* Indentation level of current line */ static int tab=0; /* First indentation found */ int included=0; /* Is current file included? */ +int lineno = 1; %} %% @@ -76,10 +77,13 @@ int included=0; /* Is current file included? */ 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]* { + lineno++; ind=indentation(yytext+1); if (tab==0) tab=ind; @@ -332,11 +336,11 @@ set_line_file(l) register char *l; while (*l<'0' || *l>'9') l++; - yylineno=0; + lineno=0; while ('0'<=*l && *l<='9') - yylineno=yylineno*10+(*l++ - '0'); + lineno=lineno*10+(*l++ - '0'); - yylineno--; + lineno--; while (*l++!='"'); diff --git a/lang/occam/comp/occam.g b/lang/occam/comp/occam.g index e78cc467e..49bc12444 100644 --- a/lang/occam/comp/occam.g +++ b/lang/occam/comp/occam.g @@ -19,7 +19,7 @@ static void nonconst(), nonpositive(), rep_cleanup(), check_assoc(); void init_builtins(); char *strcpy(); -extern int yylineno, LLsymb; +extern int lineno, LLsymb; union type_info info, none; } %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); Label(F); } - | ALT { line=yylineno; oind=ind; } - [ %if (line==yylineno) + | ALT { line=lineno; oind=ind; } + [ %if (line==lineno) replicator(&v, &e1, &e2) { rep_init(v, e1, e2, &to_test); } guarded_process(END) @@ -144,8 +144,8 @@ conditional(register *END; ) { struct symbol *v; { branch(END); Label(F); } - | IF { line=yylineno; oind=ind; } - [ %if (line==yylineno) + | IF { line=lineno; oind=ind; } + [ %if (line==lineno) replicator(&v, &e1, &e2) { rep_init(v, e1, e2, &to_test); } conditional(END) @@ -176,8 +176,8 @@ construct { struct symbol *v; register line, oind; int BEGIN=0, END=0, NONZERO; }: - SEQ { line=yylineno; oind=ind; } - [ %if (line==yylineno) + SEQ { line=lineno; oind=ind; } + [ %if (line==lineno) replicator(&v, &e1, &e2) { rep_init(v, e1, e2, &to_test); } process @@ -188,10 +188,10 @@ construct { struct symbol *v; [ %while (tabulated(oind, ind)) process ]* ] | PRI ? - [ PAR { line=yylineno; oind=ind; + [ PAR { line=lineno; oind=ind; par_begin(); } - [ %if (line==yylineno) + [ %if (line==lineno) replicator(&v, &e1, &e2) { rep_init(v, e1, e2, &to_test); NONZERO=0; @@ -217,11 +217,11 @@ construct { struct symbol *v; { Label(END); par_end(); } - | ALT { line=yylineno; oind=ind; + | ALT { line=lineno; oind=ind; no_deadlock(); Label(new_label(&BEGIN)); } - [ %if (line==yylineno) + [ %if (line==lineno) replicator(&v, &e1, &e2) { rep_init(v, e1, e2, &to_test); } guarded_process(&END) @@ -237,8 +237,8 @@ construct { struct symbol *v; Label(END); } ] - | IF { line=yylineno; oind=ind; } - [ %if (line==yylineno) + | IF { line=lineno; oind=ind; } + [ %if (line==lineno) replicator(&v, &e1, &e2) { rep_init(v, e1, e2, &to_test); } conditional(&END) @@ -453,7 +453,7 @@ item(register struct expr **e;) int byte, err=0, subs_call=0; struct expr_list *elp=nil, **aelp= &elp; }: - IDENTIFIER { line=yylineno; + IDENTIFIER { line=lineno; oind=ind; var=searchall(token.t_sval); @@ -465,7 +465,7 @@ item(register struct expr **e;) *e=new_var(var); } } - [ %while (line==yylineno || tabulated(oind, ind)) + [ %while (line==lineno || tabulated(oind, ind)) [ subscript(&byte, &e1) { *e=new_node('[', *e, e1, byte); } | '(' { if (!var_declared(var)) { diff --git a/lang/occam/comp/report.c b/lang/occam/comp/report.c index 7cc8f9f28..76252bdda 100644 --- a/lang/occam/comp/report.c +++ b/lang/occam/comp/report.c @@ -5,13 +5,13 @@ */ #include -extern int err, yylineno; +extern int err, lineno; extern char *curr_file; /*VARARGS1*/ 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,"\n"); err=1; @@ -20,7 +20,7 @@ report(fmt, arg1, arg2, arg3) char *fmt; /*VARARGS1*/ 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,"\n"); } @@ -28,7 +28,7 @@ warning(fmt, arg1, arg2, arg3) char *fmt, *arg1; /*VARARGS1*/ 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,"\n"); exit(1); -- 2.34.1