Home | History | Annotate | Line # | Download | only in error
      1  1.25    andvar /*	$NetBSD: pi.c,v 1.25 2025/07/11 22:19:54 andvar Exp $	*/
      2   1.3       jtc 
      3   1.1       cgd /*
      4   1.3       jtc  * Copyright (c) 1980, 1993
      5   1.3       jtc  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1       cgd  * modification, are permitted provided that the following conditions
      9   1.1       cgd  * are met:
     10   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15  1.11       agc  * 3. Neither the name of the University nor the names of its contributors
     16   1.1       cgd  *    may be used to endorse or promote products derived from this software
     17   1.1       cgd  *    without specific prior written permission.
     18   1.1       cgd  *
     19   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29   1.1       cgd  * SUCH DAMAGE.
     30   1.1       cgd  */
     31   1.1       cgd 
     32   1.4     lukem #include <sys/cdefs.h>
     33   1.1       cgd #ifndef lint
     34   1.3       jtc #if 0
     35   1.3       jtc static char sccsid[] = "@(#)pi.c	8.1 (Berkeley) 6/6/93";
     36   1.3       jtc #endif
     37  1.25    andvar __RCSID("$NetBSD: pi.c,v 1.25 2025/07/11 22:19:54 andvar Exp $");
     38   1.1       cgd #endif /* not lint */
     39   1.1       cgd 
     40   1.1       cgd #include <stdio.h>
     41   1.1       cgd #include <ctype.h>
     42   1.1       cgd #include <string.h>
     43  1.12  christos #include <stdlib.h>
     44   1.1       cgd #include "error.h"
     45   1.1       cgd 
     46  1.17  dholland #if 0 /* not const-correct */
     47  1.17  dholland static char *unk_hdr[] = {"In", "program", "???"};
     48  1.17  dholland #else
     49  1.17  dholland DECL_STRINGS_3(static, unk_hdr, "In", "program", "???");
     50  1.17  dholland #endif
     51  1.17  dholland 
     52  1.14  dholland static char *c_linenumber;
     53  1.14  dholland static char **c_header = &unk_hdr[0];
     54   1.1       cgd 
     55  1.22    rillig static bool alldigits(const char *);
     56  1.22    rillig static bool isdateformat(int, char **);
     57  1.22    rillig static bool instringset(const char *, const char **);
     58  1.22    rillig static bool piptr(const char *);
     59   1.4     lukem 
     60   1.4     lukem 
     61   1.1       cgd /*
     62  1.14  dholland  * Attempt to handle error messages produced by pi (and by pc)
     63   1.1       cgd  *
     64   1.1       cgd  *	problem #1:	There is no file name available when a file does not
     65   1.1       cgd  *			use a #include; this will have to be given to error
     66   1.1       cgd  *			in the command line.
     67   1.1       cgd  *	problem #2:	pi doesn't always tell you what line number
     68   1.1       cgd  *			a error refers to; for example during the tree
     69   1.1       cgd  *			walk phase of code generation and error detection,
     70   1.1       cgd  *			an error can refer to "variable foo in procedure bletch"
     71   1.1       cgd  *			without giving a line number
     72   1.1       cgd  *	problem #3:	line numbers, when available, are attached to
     73   1.1       cgd  *			the source line, along with the source line itself
     74   1.1       cgd  *			These line numbers must be extracted, and
     75   1.1       cgd  *			the source line thrown away.
     76   1.1       cgd  *	problem #4:	Some error messages produce more than one line number
     77   1.1       cgd  *			on the same message.
     78   1.1       cgd  *			There are only two (I think):
     79   1.1       cgd  *				%s undefined on line%s
     80   1.1       cgd  *				%s improperly used on line%s
     81   1.1       cgd  *			here, the %s makes line plural or singular.
     82   1.1       cgd  *
     83   1.1       cgd  *	Here are the error strings used in pi version 1.2 that can refer
     84   1.1       cgd  *	to a file name or line number:
     85   1.1       cgd  *
     86   1.1       cgd  *		Multiply defined label in case, lines %d and %d
     87   1.1       cgd  *		Goto %s from line %d is into a structured statement
     88   1.1       cgd  *		End matched %s on line %d
     89   1.1       cgd  *		Inserted keyword end matching %s on line %d
     90   1.1       cgd  *
     91   1.1       cgd  *	Here are the general pi patterns recognized:
     92   1.1       cgd  *	define piptr == -.*^-.*
     93   1.1       cgd  *	define msg = .*
     94   1.1       cgd  *	define digit = [0-9]
     95   1.1       cgd  *	definename = .*
     96  1.14  dholland  *	define date_format letter*3 letter*3 (digit | (digit digit))
     97   1.1       cgd  *			(digit | (digit digit)):digit*2 digit*4
     98   1.1       cgd  *
     99   1.1       cgd  *	{e,E} (piptr) (msg)	Encounter an error during textual scan
    100   1.1       cgd  *	E {digit}* - (msg)	Have an error message that refers to a new line
    101   1.1       cgd  *	E - msg			Have an error message that refers to current
    102   1.1       cgd  *					function, program or procedure
    103   1.1       cgd  *	(date_format) (name):	When switch compilation files
    104   1.1       cgd  *	... (msg)		When refer to the previous line
    105   1.1       cgd  *	'In' ('procedure'|'function'|'program') (name):
    106   1.1       cgd  *				pi is now complaining about 2nd pass errors.
    107  1.14  dholland  *
    108   1.1       cgd  *	Here is the output from a compilation
    109   1.1       cgd  *
    110   1.1       cgd  *
    111   1.1       cgd  *	     2  	var	i:integer;
    112   1.1       cgd  *	e --------------^--- Inserted ';'
    113   1.1       cgd  *	E 2 - All variables must be declared in one var part
    114   1.1       cgd  *	E 5 - Include filename must end in .i
    115   1.1       cgd  *	Mon Apr 21 15:56 1980  test.h:
    116   1.1       cgd  *	     2  begin
    117   1.1       cgd  *	e ------^--- Inserted ';'
    118   1.1       cgd  *	Mon Apr 21 16:06 1980  test.p:
    119   1.1       cgd  *	E 2 - Function type must be specified
    120   1.1       cgd  *	     6  procedure foo(var x:real);
    121   1.1       cgd  *	e ------^--- Inserted ';'
    122   1.1       cgd  *	In function bletch:
    123   1.1       cgd  *	  E - No assignment to the function variable
    124   1.1       cgd  *	  w - variable x is never used
    125   1.1       cgd  *	E 6 - foo is already defined in this block
    126   1.1       cgd  *	In procedure foo:
    127   1.1       cgd  *	  w - variable x is neither used nor set
    128   1.1       cgd  *	     9  	z : = 23;
    129   1.1       cgd  *	E --------------^--- Undefined variable
    130   1.1       cgd  *	    10  	y = [1];
    131   1.1       cgd  *	e ----------------^--- Inserted ':'
    132   1.1       cgd  *	    13  	z := 345.;
    133   1.1       cgd  *	e -----------------------^--- Digits required after decimal point
    134   1.1       cgd  *	E 10 - Constant set involved in non set context
    135   1.1       cgd  *	E 11 - Type clash: real is incompatible with integer
    136   1.1       cgd  *	   ... Type of expression clashed with type of variable in assignment
    137   1.1       cgd  *	E 12 - Parameter type not identical to type of var parameter x of foo
    138   1.1       cgd  *	In program mung:
    139   1.1       cgd  *	  w - variable y is never used
    140   1.1       cgd  *	  w - type foo is never used
    141   1.1       cgd  *	  w - function bletch is never used
    142   1.1       cgd  *	  E - z undefined on lines 9 13
    143   1.1       cgd  */
    144  1.17  dholland static const char *Months[] = {
    145   1.1       cgd 	"Jan", "Feb", "Mar", "Apr", "May", "Jun",
    146  1.14  dholland 	"Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
    147  1.23    rillig 	NULL
    148   1.1       cgd };
    149  1.17  dholland static const char *Days[] = {
    150  1.23    rillig 	"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL
    151   1.1       cgd };
    152  1.17  dholland static const char *Piroutines[] = {
    153  1.23    rillig 	"program", "function", "procedure", NULL
    154   1.1       cgd };
    155   1.1       cgd 
    156   1.1       cgd 
    157  1.22    rillig static bool structured, multiple;
    158   1.1       cgd 
    159  1.17  dholland #if 0 /* not const-correct */
    160  1.13  dholland static char *pi_Endmatched[] = {"End", "matched"};
    161  1.13  dholland static char *pi_Inserted[] = {"Inserted", "keyword", "end", "matching"};
    162   1.1       cgd 
    163  1.20    andvar static char *pi_multiple[] = {"Multiply", "defined", "label", "in", "case,", "line"};
    164  1.13  dholland static char *pi_structured[] = {"is", "into", "a", "structured", "statement"};
    165   1.1       cgd 
    166  1.13  dholland static char *pi_und1[] = {"undefined", "on", "line"};
    167  1.13  dholland static char *pi_und2[] = {"undefined", "on", "lines"};
    168  1.13  dholland static char *pi_imp1[] = {"improperly", "used", "on", "line"};
    169  1.13  dholland static char *pi_imp2[] = {"improperly", "used", "on", "lines"};
    170   1.1       cgd 
    171  1.17  dholland #else
    172  1.17  dholland DECL_STRINGS_2(static, pi_Endmatched, "End", "matched");
    173  1.17  dholland DECL_STRINGS_4(static, pi_Inserted, "Inserted", "keyword", "end", "matching");
    174  1.17  dholland 
    175  1.17  dholland DECL_STRINGS_6(static, pi_multiple,
    176  1.20    andvar 	       "Multiply", "defined", "label", "in", "case,", "line");
    177  1.17  dholland DECL_STRINGS_5(static, pi_structured,
    178  1.17  dholland 	       "is", "into", "a", "structured", "statement");
    179  1.17  dholland 
    180  1.17  dholland DECL_STRINGS_3(static, pi_und1, "undefined", "on", "line");
    181  1.17  dholland DECL_STRINGS_3(static, pi_und2, "undefined", "on", "lines");
    182  1.17  dholland DECL_STRINGS_4(static, pi_imp1, "improperly", "used", "on", "line");
    183  1.17  dholland DECL_STRINGS_4(static, pi_imp2, "improperly", "used", "on", "lines");
    184  1.17  dholland 
    185  1.17  dholland #endif
    186  1.17  dholland 
    187  1.22    rillig static bool
    188  1.15  dholland alldigits(const char *string)
    189   1.1       cgd {
    190  1.22    rillig 	for (; *string != '\0' && isdigit((unsigned char)*string); string++)
    191   1.1       cgd 		continue;
    192  1.21    rillig 	return *string == '\0';
    193   1.1       cgd }
    194   1.4     lukem 
    195  1.22    rillig static bool
    196  1.17  dholland instringset(const char *member, const char **set)
    197   1.1       cgd {
    198  1.22    rillig 	for (; *set != NULL; set++)
    199   1.1       cgd 		if (strcmp(*set, member) == 0)
    200  1.16  dholland 			return true;
    201  1.16  dholland 	return false;
    202   1.1       cgd }
    203   1.1       cgd 
    204  1.22    rillig static bool
    205   1.9       wiz isdateformat(int wordc, char **wordv)
    206   1.1       cgd {
    207  1.21    rillig 	return  wordc == 5
    208  1.21    rillig 	     && instringset(wordv[0], Days)
    209  1.21    rillig 	     && instringset(wordv[1], Months)
    210  1.21    rillig 	     && alldigits(wordv[2])
    211  1.21    rillig 	     && alldigits(wordv[4]);
    212   1.1       cgd }
    213   1.1       cgd 
    214  1.22    rillig static bool
    215  1.15  dholland piptr(const char *string)
    216   1.1       cgd {
    217   1.1       cgd 	if (*string != '-')
    218  1.16  dholland 		return false;
    219  1.19  dholland 	while (*string == '-')
    220   1.1       cgd 		string++;
    221   1.1       cgd 	if (*string != '^')
    222  1.16  dholland 		return false;
    223   1.1       cgd 	string++;
    224  1.19  dholland 	while (*string == '-')
    225   1.1       cgd 		string++;
    226  1.21    rillig 	return *string == '\0';
    227   1.1       cgd }
    228   1.1       cgd 
    229   1.4     lukem Errorclass
    230   1.9       wiz pi(void)
    231   1.1       cgd {
    232  1.14  dholland 	char **nwordv;
    233   1.1       cgd 
    234   1.4     lukem 	nwordv = NULL;
    235  1.16  dholland 	if (cur_wordc < 2)
    236  1.21    rillig 		return C_UNKNOWN;
    237  1.16  dholland 	if (strlen(cur_wordv[1]) == 1
    238  1.16  dholland 	    && ( cur_wordv[1][0] == 'e' || cur_wordv[1][0] == 'E')
    239  1.16  dholland 	    && piptr(cur_wordv[2])
    240   1.1       cgd 	) {
    241  1.22    rillig 		bool longpiptr = false;
    242  1.14  dholland 
    243   1.1       cgd 		/*
    244   1.1       cgd 		 *	We have recognized a first pass error of the form:
    245   1.1       cgd 		 *	letter ------^---- message
    246   1.1       cgd 		 *
    247   1.1       cgd 		 *	turn into an error message of the form:
    248   1.1       cgd 		 *
    249   1.1       cgd 		 *	file line 'pascal errortype' letter \n |---- message
    250   1.1       cgd 		 *	or of the form:
    251   1.1       cgd 		 *	file line letter |---- message
    252   1.1       cgd 		 *		when there are strlen("(*[pi]") or more
    253   1.1       cgd 		 *		preceding '-' on the error pointer.
    254   1.1       cgd 		 *
    255   1.1       cgd 		 *	Where the | is intended to be a down arrow, so that
    256   1.1       cgd 		 *	the pi error messages can be inserted above the
    257   1.1       cgd 		 *	line in error, instead of below.  (All of the other
    258   1.7       mjl 		 *	languages put their messages before the source line,
    259   1.1       cgd 		 *	instead of after it as does pi.)
    260   1.1       cgd 		 *
    261   1.1       cgd 		 *	where the pointer to the error has been truncated
    262   1.1       cgd 		 *	by 6 characters to account for the fact that
    263   1.1       cgd 		 *	the pointer points into a tab preceded input line.
    264   1.1       cgd 		 */
    265   1.1       cgd 		language = INPI;
    266  1.16  dholland 		(void)substitute(cur_wordv[2], '^', '|');
    267  1.16  dholland 		longpiptr = position(cur_wordv[2],'|') > (6+8);
    268  1.16  dholland 		nwordv = wordvsplice(longpiptr ? 2 : 4, cur_wordc, cur_wordv+1);
    269  1.10    itojun 		nwordv[0] = strdup(currentfilename);
    270  1.10    itojun 		nwordv[1] = strdup(c_linenumber);
    271  1.14  dholland 		if (!longpiptr) {
    272  1.17  dholland 			nwordv[2] = Strdup("pascal errortype"); /* XXX leaked */
    273  1.16  dholland 			nwordv[3] = cur_wordv[1];
    274  1.10    itojun 			nwordv[4] = strdup("%%%\n");
    275   1.1       cgd 			if (strlen(nwordv[5]) > (8-2))	/* this is the pointer */
    276   1.1       cgd 				nwordv[5] += (8-2);	/* bump over 6 characters */
    277   1.1       cgd 		}
    278  1.16  dholland 		cur_wordv = nwordv - 1;		/* convert to 1 based */
    279  1.16  dholland 		cur_wordc += longpiptr ? 2 : 4;
    280  1.21    rillig 		return C_TRUE;
    281   1.1       cgd 	}
    282  1.16  dholland 	if (cur_wordc >= 4
    283  1.16  dholland 	    && strlen(cur_wordv[1]) == 1
    284  1.16  dholland 	    && (*cur_wordv[1] == 'E' || *cur_wordv[1] == 'w' || *cur_wordv[1] == 'e')
    285  1.16  dholland 	    && alldigits(cur_wordv[2])
    286  1.16  dholland 	    && strlen(cur_wordv[3]) == 1
    287  1.16  dholland 	    && cur_wordv[3][0] == '-'
    288  1.14  dholland 	) {
    289   1.1       cgd 		/*
    290  1.14  dholland 		 * Message of the form: letter linenumber - message
    291  1.14  dholland 		 * Turn into form: filename linenumber letter - message
    292   1.1       cgd 		 */
    293   1.1       cgd 		language = INPI;
    294  1.16  dholland 		nwordv = wordvsplice(1, cur_wordc, cur_wordv + 1);
    295  1.10    itojun 		nwordv[0] = strdup(currentfilename);
    296  1.16  dholland 		nwordv[1] = cur_wordv[2];
    297  1.16  dholland 		nwordv[2] = cur_wordv[1];
    298  1.16  dholland 		c_linenumber = cur_wordv[2];
    299  1.16  dholland 		cur_wordc += 1;
    300  1.16  dholland 		cur_wordv = nwordv - 1;
    301  1.21    rillig 		return C_TRUE;
    302   1.1       cgd 	}
    303  1.16  dholland 	if (cur_wordc >= 3
    304  1.16  dholland 	    && strlen(cur_wordv[1]) == 1
    305  1.16  dholland 	    && (*cur_wordv[1] == 'E' || *cur_wordv[1] == 'w' || *cur_wordv[1] == 'e')
    306  1.16  dholland 	    && strlen(cur_wordv[2]) == 1
    307  1.16  dholland 	    && cur_wordv[2][0] == '-'
    308   1.1       cgd 	) {
    309   1.1       cgd 		/*
    310  1.14  dholland 		 * Message of the form: letter - message
    311  1.14  dholland 		 *
    312  1.14  dholland 		 * This happens only when we are traversing the tree
    313  1.14  dholland 		 * during the second pass of pi, and discover semantic
    314  1.14  dholland 		 * errors.
    315  1.14  dholland 		 *
    316  1.14  dholland 		 * We have already (presumably) saved the header message
    317  1.14  dholland 		 * and can now construct a nulled error message for the
    318  1.14  dholland 		 * current file.
    319   1.1       cgd 		 *
    320  1.14  dholland 		 * Turns into a message of the form:
    321  1.14  dholland 		 *      filename (header) letter - message
    322   1.1       cgd 		 *
    323  1.14  dholland 		 * First, see if it is a message referring to more than
    324  1.14  dholland 		 * one line number.  Only of the form:
    325  1.14  dholland  		 *      %s undefined on line%s
    326  1.14  dholland  		 *      %s improperly used on line%s
    327   1.1       cgd 		 */
    328  1.22    rillig 		bool undefined = false;
    329  1.14  dholland 		int wordindex;
    330   1.1       cgd 
    331   1.1       cgd 		language = INPI;
    332  1.24    rillig 		if ((undefined = wordv_eq(cur_wordv+2, 3, pi_und1))
    333  1.24    rillig 		     || (undefined = wordv_eq(cur_wordv+2, 3, pi_und2))
    334  1.24    rillig 		     || wordv_eq(cur_wordv+2, 4, pi_imp1)
    335  1.24    rillig 		     || wordv_eq(cur_wordv+2, 4, pi_imp2)
    336  1.14  dholland 		) {
    337  1.16  dholland 			for (wordindex = undefined ? 5 : 6;
    338  1.16  dholland 			     wordindex <= cur_wordc;
    339  1.16  dholland 			     wordindex++) {
    340  1.22    rillig 				if (nwordv != NULL) {
    341  1.12  christos 					free(nwordv[0]);
    342  1.12  christos 					free(nwordv);
    343  1.12  christos 				}
    344  1.16  dholland 				nwordv = wordvsplice(2, undefined ? 2 : 3, cur_wordv+1);
    345  1.10    itojun 				nwordv[0] = strdup(currentfilename);
    346  1.16  dholland 				nwordv[1] = cur_wordv[wordindex];
    347  1.16  dholland 				if (wordindex != cur_wordc)
    348   1.1       cgd 					erroradd(undefined ? 4 : 5, nwordv,
    349   1.1       cgd 						C_TRUE, C_UNKNOWN);
    350   1.1       cgd 			}
    351  1.16  dholland 			cur_wordc = undefined ? 4 : 5;
    352  1.16  dholland 			cur_wordv = nwordv - 1;
    353  1.21    rillig 			return C_TRUE;
    354   1.1       cgd 		}
    355   1.1       cgd 
    356  1.16  dholland 		nwordv = wordvsplice(1+3, cur_wordc, cur_wordv+1);
    357  1.10    itojun 		nwordv[0] = strdup(currentfilename);
    358  1.10    itojun 		nwordv[1] = strdup(c_header[0]);
    359  1.10    itojun 		nwordv[2] = strdup(c_header[1]);
    360  1.10    itojun 		nwordv[3] = strdup(c_header[2]);
    361  1.16  dholland 		cur_wordv = nwordv - 1;
    362  1.16  dholland 		cur_wordc += 1 + 3;
    363  1.21    rillig 		return C_THISFILE;
    364   1.1       cgd 	}
    365  1.22    rillig 	if (strcmp(cur_wordv[1], "...") == 0 && c_linenumber != NULL &&
    366  1.18  christos 	    currentfilename != default_currentfilename) {
    367   1.1       cgd 		/*
    368  1.14  dholland 		 * have a continuation error message
    369  1.14  dholland 		 * of the form: ... message
    370  1.14  dholland 		 * Turn into form : filename linenumber message
    371   1.1       cgd 		 */
    372   1.1       cgd 		language = INPI;
    373  1.16  dholland 		nwordv = wordvsplice(1, cur_wordc, cur_wordv+1);
    374  1.10    itojun 		nwordv[0] = strdup(currentfilename);
    375  1.10    itojun 		nwordv[1] = strdup(c_linenumber);
    376  1.16  dholland 		cur_wordv = nwordv - 1;
    377  1.16  dholland 		cur_wordc += 1;
    378  1.21    rillig 		return C_TRUE;
    379   1.1       cgd 	}
    380  1.16  dholland 	if (cur_wordc == 6
    381  1.16  dholland 	   && lastchar(cur_wordv[6]) == ':'
    382  1.16  dholland 	   && isdateformat(5, cur_wordv + 1)
    383  1.14  dholland 	) {
    384   1.1       cgd 		/*
    385  1.14  dholland 		 * Have message that tells us we have changed files
    386   1.1       cgd 		 */
    387   1.1       cgd 		language = INPI;
    388  1.16  dholland 		currentfilename = strdup(cur_wordv[6]);
    389   1.1       cgd 		clob_last(currentfilename, '\0');
    390  1.21    rillig 		return C_SYNC;
    391   1.1       cgd 	}
    392  1.16  dholland 	if (cur_wordc == 3
    393  1.16  dholland 	   && strcmp(cur_wordv[1], "In") == 0
    394  1.16  dholland 	   && lastchar(cur_wordv[3]) == ':'
    395  1.16  dholland 	   && instringset(cur_wordv[2], Piroutines)
    396   1.1       cgd 	) {
    397   1.1       cgd 		language = INPI;
    398  1.16  dholland 		c_header = wordvsplice(0, cur_wordc, cur_wordv+1);
    399  1.21    rillig 		return C_SYNC;
    400   1.1       cgd 	}
    401  1.14  dholland 
    402   1.1       cgd 	/*
    403  1.14  dholland 	 * now, check for just the line number followed by the text
    404   1.1       cgd 	 */
    405  1.16  dholland 	if (alldigits(cur_wordv[1])) {
    406   1.1       cgd 		language = INPI;
    407  1.16  dholland 		c_linenumber = cur_wordv[1];
    408  1.21    rillig 		return C_IGNORE;
    409   1.1       cgd 	}
    410  1.14  dholland 
    411   1.1       cgd 	/*
    412  1.25    andvar 	 * Attempt to match messages referring to a line number
    413   1.1       cgd 	 *
    414  1.14  dholland 	 * Multiply defined label in case, lines %d and %d
    415  1.14  dholland 	 * Goto %s from line %d is into a structured statement
    416  1.14  dholland 	 * End matched %s on line %d
    417  1.14  dholland 	 * Inserted keyword end matching %s on line %d
    418   1.1       cgd 	 */
    419  1.23    rillig 	structured = false;
    420  1.23    rillig 	multiple = false;
    421   1.1       cgd 	if (
    422  1.24    rillig 	       (cur_wordc == 6 && wordv_eq(cur_wordv+1, 2, pi_Endmatched))
    423  1.24    rillig 	    || (cur_wordc == 8 && wordv_eq(cur_wordv+1, 4, pi_Inserted))
    424  1.24    rillig 	    || (multiple = (cur_wordc == 9 && wordv_eq(cur_wordv+1,6, pi_multiple)))
    425  1.24    rillig 	    || (structured = (cur_wordc == 10 && wordv_eq(cur_wordv+6,5, pi_structured)))
    426  1.14  dholland 	) {
    427   1.1       cgd 		language = INPI;
    428  1.16  dholland 		nwordv = wordvsplice(2, cur_wordc, cur_wordv+1);
    429  1.10    itojun 		nwordv[0] = strdup(currentfilename);
    430  1.16  dholland 		nwordv[1] = structured ? cur_wordv [5] : cur_wordv[cur_wordc];
    431  1.16  dholland 		cur_wordc += 2;
    432  1.16  dholland 		cur_wordv = nwordv - 1;
    433   1.1       cgd 		if (!multiple)
    434  1.21    rillig 			return C_TRUE;
    435  1.16  dholland 		erroradd(cur_wordc, nwordv, C_TRUE, C_UNKNOWN);
    436  1.16  dholland 		nwordv = wordvsplice(0, cur_wordc, nwordv);
    437  1.16  dholland 		nwordv[1] = cur_wordv[cur_wordc - 2];
    438  1.21    rillig 		return C_TRUE;
    439   1.1       cgd 	}
    440  1.21    rillig 	return C_UNKNOWN;
    441   1.1       cgd }
    442