[comp.sys.mac.programmer] Flex for MPW

morten@cs.qmw.ac.uk (Morten Ronseth) (08/13/90)

For the last couple of days, I've been trying to port flex to the MPW
environment. Everything compiles just fine, no problems there.
But, whatever *.l file i run flex on, it seems to gag and die. For
example, on an empty input file, it does
	---accepting rule: #116 fatal parse error at 1.
falls over and dies. On a file containing

	%{
	#include "hello.h"
	%}

it spits out:
	---accepting rule: #116
	---accepting rule: #116
	---accepting rule: #0
	---accepting rule: #16 syntax error at line 1: illegale character
	---accepting rule: #116
	---accepting rule: #0
	---accepting rule: #115
	flex: flex scanner jammed


Now the state of the machine is:
	yy_act = 16
	yytext = "%"
	yy_current_state = 51
	yy_hold_char = 123

right after `yy_act = yy_accept[yy_current_state]' in the second `while (1)' loop
in flexscan. Can anyone tell me why it chokes on an input like this?

This might not be the correct group to post this to, but I thought I'd give it
a go.


		Morten.
-- 
====================================================================
Morten Lerskau Ronseth             UUCP:   morten@qmw-cs.uucp
Dept. of Computer Science          JANET:  morten@uk.ac.qmw.cs 
Queen Mary and Westfield College   ARPA:   morten%qmw.cs@ucl-cs.arpa 
Mile End Road                      Easylink:  19019285 
London E1 4NS                      Tlf:       071 975 5220 
England.                           Dept. fax: 081 980 6533 

morten@cs.qmw.ac.uk (Morten Ronseth) (08/13/90)

I just realized that even lex falls over in the two cases I've mentioned.
But that doesn't really make any difference, since my flex even dies on the
`scan.l' file in the flex sources. So something is wrong...

		Morten.
-- 
====================================================================
Morten Lerskau Ronseth             UUCP:   morten@qmw-cs.uucp
Dept. of Computer Science          JANET:  morten@uk.ac.qmw.cs 
Queen Mary and Westfield College   ARPA:   morten%qmw.cs@ucl-cs.arpa 
Mile End Road                      Easylink:  19019285 
London E1 4NS                      Tlf:       071 975 5220 
England.                           Dept. fax: 081 980 6533 

earleh@microsoft.UUCP (Earle HORTON) (08/16/90)

In article <2632@sequent.cs.qmw.ac.uk> morten@cs.qmw.ac.uk (Morten Ronseth) writes:
>
>For the last couple of days, I've been trying to port flex to the MPW
>environment. Everything compiles just fine, no problems there.
>But, whatever *.l file i run flex on, it seems to gag and die. For
>example, on an empty input file, it does...

>... Can anyone tell me why it chokes on an input like this?
>
>This might not be the correct group to post this to, but I thought I'd give it
>a go.

     It is probably because under the MPW C compiler, '\n' is actually
13, 0x0d, \015, more conventionally named '\r' under other C implementations.
As far as the scanner tables in "scan.c" are concerned, however, the
Macintosh end-of-line character is just some random control character,
not needing the special consideration given to a "real" linefeed.

     Find the equivalence class translation table in "scan.c" and transpose
the (zero-based) tenth and thirteenth elements.  Then go through the code
and fix up all the places where it is assumed that '\n' is equal to
decimal 10.  Then implement a bunch more fixes to allow Flex to scan
Macintosh extended character set characters.  Better yet, get a copy of
the already-ported-to-the-Macintosh version.  Available via ftp from
apple.com and sumex-aim.stanford.edu.  Also available from me in exchange
for SASE, formatted 800k floppy, and sufficient postage to get it back to
you.

Earle Horton