[comp.bugs.4bsd] Berkeley Pascal parses := etc incorrectly

rcodi@koel.rmit.oz (Ian Donaldson) (08/31/88)

Description:
	Berkeley pascal parses ":=", "<>", "<=", ">="  incorrectly.

	Any amount of white space is allowed to intervene between the
	two characters.  This is incorrect pascal, and in the case
	of SunOS contravenes the syntax diagrams on pages 97 and 98
	of the Sun Pascal programmers guide.

Compilers:
	Both pi and pc

O/S's:
	SunOS 3.5
	4.3bsd
	probably others

Repeat-by:
	Compile the following program and note that there are -no-
	errors diagnosed.


	----------
	program x(output);

	var
		a: integer;
	begin
		a :
		    = 3;
		if a <
		    > 3 then
		    writeln('amazing')
	end.
	----------

	Compile it again with the "-s" option and note that there
	still aren't any errors.  This program is NOT a standard
	pascal program, but Berkeley pascal allows it.

Fix:
	In 4.3bsd pc/pi,  ":" and "=" are taken as
	separate tokens and if adjacent form the ":=" token.  The
	problem is that there is no code that checks for exact
	adjacency; ie: leading white space may intervene (as with
	all other tokens)

	In "/usr/src/ucb/pascal/src/yylex.c" the characters ":" 
	and "=" are returned as individual tokens without checking the 
	next character.
	
	In "/usr/src/ucb/pascal/src/pas.y" the tokens for ':' and
	'=' are checked for adjacency, but a second call to yylex() for
	the 2nd character will skip intervening blanks between them.

	yylex() needs to identify special 2-character tokens and
	return a magic cookie for each type, rather than returning
	just the individual characters.

Ian D