CVS: sml/src/ml-yacc/src yacc.lex,1.2,1.3 yacc.lex.sml,1.3,1.4

John Reppy <[email protected]>
Newsgroups gmane.comp.lang.sml.smlnj.commits
Message-ID <[email protected]>
Update of /cvsroot/smlnj/sml/src/ml-yacc/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1980/src/ml-yacc/src

Modified Files:
	yacc.lex yacc.lex.sml 
Log Message:
  Fixed ml-yacc to work with non-native eol encodings.


Index: yacc.lex
===================================================================
RCS file: /cvsroot/smlnj/sml/src/ml-yacc/src/yacc.lex,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** yacc.lex	1 Jun 2000 18:33:44 -0000	1.2
--- yacc.lex	27 Jul 2005 16:14:49 -0000	1.3
***************
*** 40,49 ****
  	       ("%arg",PERCENT_ARG),
  	       ("%pos",PERCENT_POS)]
! in val lookup =
!      fn (s,left,right) =>
! 	 let fun f ((a,d)::b) = if a=s then d(left,right) else f b
! 	       | f nil = UNKNOWN(s,left,right)
! 	 in f dict
! 	 end
  end
  
--- 40,50 ----
  	       ("%arg",PERCENT_ARG),
  	       ("%pos",PERCENT_POS)]
! in
! fun lookup (s,left,right) = let
!        fun f ((a,d)::b) = if a=s then d(left,right) else f b
! 	 | f nil = UNKNOWN(s,left,right)
!        in
! 	  f dict
!        end
  end
  
***************
*** 61,64 ****
--- 62,66 ----
  %s A CODE F COMMENT STRING EMPTYCOMMENT;
  ws = [\t\ ]+;
+ eol=("\n"|"\013\n"|"\013");
  idchars = [A-Za-z_'0-9];
  id=[A-Za-z]{idchars}*;
***************
*** 71,80 ****
  <CODE>"(*"	=> (Add yytext; YYBEGIN COMMENT; commentLevel := 1;
  		    continue() before YYBEGIN CODE);
! <INITIAL>[^%\n]+ => (Add yytext; continue());
  <INITIAL>"%%"	 => (YYBEGIN A; HEADER (concat (rev (!text)),!lineno,!lineno));
! <INITIAL,CODE,COMMENT,F,EMPTYCOMMENT>\n  => (Add yytext; inc lineno; continue());
  <INITIAL>.	 => (Add yytext; continue());
  
! <A>\n		=> (inc lineno; continue ());
  <A>{ws}+	=> (continue());
  <A>of		=> (OF(!lineno,!lineno));
--- 73,82 ----
  <CODE>"(*"	=> (Add yytext; YYBEGIN COMMENT; commentLevel := 1;
  		    continue() before YYBEGIN CODE);
! <INITIAL>[^%\013\n]+ => (Add yytext; continue());
  <INITIAL>"%%"	 => (YYBEGIN A; HEADER (concat (rev (!text)),!lineno,!lineno));
! <INITIAL,CODE,COMMENT,F,EMPTYCOMMENT>{eol}  => (Add yytext; inc lineno; continue());
  <INITIAL>.	 => (Add yytext; continue());
  
! <A>{eol}	=> (inc lineno; continue ());
  <A>{ws}+	=> (continue());
  <A>of		=> (OF(!lineno,!lineno));
***************
*** 105,109 ****
  		    else (Add yytext; continue()));
  <CODE>"\""	=> (Add yytext; YYBEGIN STRING; continue());
! <CODE>[^()"\n]+	=> (Add yytext; continue());
  
  <COMMENT>[(*)]	=> (Add yytext; continue());
--- 107,111 ----
  		    else (Add yytext; continue()));
  <CODE>"\""	=> (Add yytext; YYBEGIN STRING; continue());
! <CODE>[^()"\n\013]+ => (Add yytext; continue());
  
  <COMMENT>[(*)]	=> (Add yytext; continue());
***************
*** 114,118 ****
  		   );
  <COMMENT>"(*"	=> (Add yytext; inc commentLevel; continue());
! <COMMENT>[^*()\n]+ => (Add yytext; continue());
  
  <EMPTYCOMMENT>[(*)]  => (continue());
--- 116,120 ----
  		   );
  <COMMENT>"(*"	=> (Add yytext; inc commentLevel; continue());
! <COMMENT>[^*()\n\013]+ => (Add yytext; continue());
  
  <EMPTYCOMMENT>[(*)]  => (continue());
***************
*** 121,135 ****
  			  continue ());
  <EMPTYCOMMENT>"(*"   => (inc commentLevel; continue());
! <EMPTYCOMMENT>[^*()\n]+ => (continue());
  
  <STRING>"\""	=> (Add yytext; YYBEGIN CODE; continue());
  <STRING>\\	=> (Add yytext; continue());
! <STRING>\n	=> (Add yytext; error inputSource (!lineno) "unclosed string";
   	            inc lineno; YYBEGIN CODE; continue());
! <STRING>[^"\\\n]+ => (Add yytext; continue());
  <STRING>\\\"	=> (Add yytext; continue());
! <STRING>\\[\ \t\n]   => (Add yytext;
! 			if substring(yytext,1,1)="\n" then inc lineno else ();
! 		     	YYBEGIN F; continue());
  
  <F>{ws}		=> (Add yytext; continue());
--- 123,136 ----
  			  continue ());
  <EMPTYCOMMENT>"(*"   => (inc commentLevel; continue());
! <EMPTYCOMMENT>[^*()\n\013]+ => (continue());
  
  <STRING>"\""	=> (Add yytext; YYBEGIN CODE; continue());
  <STRING>\\	=> (Add yytext; continue());
! <STRING>{eol}	=> (Add yytext; error inputSource (!lineno) "unclosed string";
   	            inc lineno; YYBEGIN CODE; continue());
! <STRING>[^"\\\n\013]+ => (Add yytext; continue());
  <STRING>\\\"	=> (Add yytext; continue());
! <STRING>\\{eol} => (Add yytext; inc lineno; YYBEGIN F; continue());
! <STRING>\\[\ \t] => (Add yytext; YYBEGIN F; continue());
  
  <F>{ws}		=> (Add yytext; continue());

Index: yacc.lex.sml
===================================================================
RCS file: /cvsroot/smlnj/sml/src/ml-yacc/src/yacc.lex.sml,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** yacc.lex.sml	1 Jun 2000 18:33:44 -0000	1.3
--- yacc.lex.sml	27 Jul 2005 16:15:03 -0000	1.4
***************
*** 49,58 ****
  	       ("%arg",PERCENT_ARG),
  	       ("%pos",PERCENT_POS)]
! in val lookup =
!      fn (s,left,right) =>
! 	 let fun f ((a,d)::b) = if a=s then d(left,right) else f b
! 	       | f nil = UNKNOWN(s,left,right)
! 	 in f dict
! 	 end
  end
  
[...1232 lines suppressed...]
! | 46 => (ASTERISK(!lineno,!lineno))
! | 49 => (ARROW(!lineno,!lineno))
  | 5 => (YYBEGIN EMPTYCOMMENT; commentLevel := 1; continue())
! | 55 => (PREC(Hdr.LEFT,!lineno,!lineno))
! | 62 => (PREC(Hdr.RIGHT,!lineno,!lineno))
! | 72 => (PREC(Hdr.NONASSOC,!lineno,!lineno))
! | 76 => let val yytext=yymktext() in lookup(yytext,!lineno,!lineno) end
! | 79 => let val yytext=yymktext() in TYVAR(yytext,!lineno,!lineno) end
  | 8 => let val yytext=yymktext() in Add yytext; YYBEGIN COMMENT; commentLevel := 1;
  		    continue() before YYBEGIN CODE end
! | 83 => let val yytext=yymktext() in IDDOT(yytext,!lineno,!lineno) end
! | 86 => let val yytext=yymktext() in INT (yytext,!lineno,!lineno) end
! | 89 => (DELIMITER(!lineno,!lineno))
! | 91 => (COLON(!lineno,!lineno))
! | 93 => (BAR(!lineno,!lineno))
! | 96 => let val yytext=yymktext() in ID ((yytext,!lineno),!lineno,!lineno) end
! | 98 => (pcount := 1; actionstart := (!lineno);
  		    text := nil; YYBEGIN CODE; continue() before YYBEGIN A)
  | _ => raise Internal.LexerError
  



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.