Subject: Spidery Web

From: [email-masked] (Patrick Weemeeuw)
Date: Thu, 29 Aug 1991 01:21:14 PDT

Hello,
I'm trying to develop a web system for Prolog.

One of the difficulties I had is recognizing tokens containing
backslashes. I changed master/spider.web such that it now correctly
handles tokens like:
token \\== category ....
generating the C string "\\==" but checking for a string with lenght *3*
instead of 4.

The context diff is included below.

Patrick.
--
Patrick Weemeeuw                   mail: Katholieke Universiteit Leuven
Tel: +32 16 200656 x 3544                Dept. of Computer Science     
e-mail: [email-masked]        Celestijnenlaan 200 A         
Fax: +32 16 205308			 B-3001 Leuven (Belgium)       
======================================================================

*** spider.web	Wed Aug 28 19:32:01 1991
--- spider.web.orig	Wed Aug 28 17:47:57 1991
***************
*** 794,800
  	tokenname[$2]="SP_gen_token_" tokennumber
  	tokennumbers[$2]=tokennumber
  	tokennumber--
- 	#<Find real length of |$2| and put it in |tokenlength[$2]|#>
  	## figure out how to recognize the token
  	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, tokenlength[$2])
  	tokentest[$2]=temp

--- 794,799 -----
  	tokenname[$2]="SP_gen_token_" tokennumber
  	tokennumbers[$2]=tokennumber
  	tokennumber--
  	## figure out how to recognize the token
  	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, length($2))
  	tokentest[$2]=temp
***************
*** 796,802
  	tokennumber--
  	#<Find real length of |$2| and put it in |tokenlength[$2]|#>
  	## figure out how to recognize the token
! 	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, tokenlength[$2])
  	tokentest[$2]=temp
  
  # To find the length of a string considered as a C~string, we scan it looking

--- 795,801 -----
  	tokennumbers[$2]=tokennumber
  	tokennumber--
  	## figure out how to recognize the token
! 	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, length($2))
  	tokentest[$2]=temp
  	tokenlength[$2]=length($2)
  
***************
*** 798,803
  	## figure out how to recognize the token
  	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, tokenlength[$2])
  	tokentest[$2]=temp
  
  # To find the length of a string considered as a C~string, we scan it looking
  for occurrences of the \.{\\} character. We initialize |templ| with

--- 797,803 -----
  	## figure out how to recognize the token
  	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, length($2))
  	tokentest[$2]=temp
+ 	tokenlength[$2]=length($2)

  # The setting of attributes is as for all tokens:
***************
*** 799,827
  	temp = sprintf( "strncmp(\"%s\",loc-1,%d)==0", $2, tokenlength[$2])
  	tokentest[$2]=temp
  
- # To find the length of a string considered as a C~string, we scan it looking
- for occurrences of the \.{\\} character. We initialize |templ| with
- |length($2)|, and each time we find a legitimate escape sequence, we decrement
- |templ|. Remark that, given the current lexical analysis, \.{\\f}, \.{\\n} etc.
- cannot occur in a token.
- #<Find real length of |$2| and put it in |tokenlength[$2]|#>=
- 	templ=length($2)
- 	i=1 #/
- 	while(i<=length($2)) { #/
- 	  if(substr($2,i,1)=="\\") { #/
- 	      if(i<length($2)) {
- 		  tempc=substr($2,i+1,1) #/
- 		  if((tempc=="a") || (tempc=="b") || (tempc=="\\") || (tempc=="?") || (tempc=="'")) {
- 			templ--
- 			i++
- 		  } else { #/
- 			i++ #/
- 		  } #/
- 	      } #/
- 	  } #/
- 	i++ #/
- 	} #/
- 	tokenlength[$2]=templ
  
  # The setting of attributes is as for all tokens:
  #<Set attributes of token |$2|#>=

--- 799,804 -----
  	tokentest[$2]=temp
  	tokenlength[$2]=length($2)

  # The setting of attributes is as for all tokens:
  #<Set attributes of token |$2|#>=