A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-checkins/2000-July/011989.html below:

python/dist/src/Parser parser.c,2.14,2.15 parser.h,2.12,2.13 parsetok.c,2.21,2.22 tokenizer.c,2.45,2.46

[Python-checkins] CVS: python/dist/src/Parser parser.c,2.14,2.15 parser.h,2.12,2.13 parsetok.c,2.21,2.22 tokenizer.c,2.45,2.46Fred L. Drake python-dev@python.org
Tue, 11 Jul 2000 10:53:03 -0700
Update of /cvsroot/python/python/dist/src/Parser
In directory slayer.i.sourceforge.net:/tmp/cvs-serv7915/Parser

Modified Files:
	parser.c parser.h parsetok.c tokenizer.c 
Log Message:

Create two new exceptions:  IndentationError and TabError.  These are
used for indentation related errors.  This patch includes Ping's
improvements for indentation-related error messages.

Closes SourceForge patches #100734 and #100856.


Index: parser.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/parser.c,v
retrieving revision 2.14
retrieving revision 2.15
diff -C2 -r2.14 -r2.15
*** parser.c	2000/07/09 03:09:56	2.14
--- parser.c	2000/07/11 17:52:59	2.15
***************
*** 206,214 ****
  
  int
! PyParser_AddToken(ps, type, str, lineno)
  	register parser_state *ps;
  	register int type;
  	char *str;
  	int lineno;
  {
  	register int ilabel;
--- 206,215 ----
  
  int
! PyParser_AddToken(ps, type, str, lineno, expected_ret)
  	register parser_state *ps;
  	register int type;
  	char *str;
  	int lineno;
+ 	int *expected_ret;
  {
  	register int ilabel;
***************
*** 286,289 ****
--- 287,299 ----
  		/* Stuck, report syntax error */
  		D(printf(" Error.\n"));
+ 		if (expected_ret) {
+ 			if (s->s_lower == s->s_upper - 1) {
+ 				/* Only one possible expected token */
+ 				*expected_ret = ps->p_grammar->
+ 				    g_ll.ll_label[s->s_lower].lb_type;
+ 			}
+ 			else 
+ 		        	*expected_ret = -1;
+ 		}
  		return E_SYNTAX;
  	}

Index: parser.h
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/parser.h,v
retrieving revision 2.12
retrieving revision 2.13
diff -C2 -r2.12 -r2.13
*** parser.h	2000/07/09 03:09:56	2.12
--- parser.h	2000/07/11 17:52:59	2.13
***************
*** 39,43 ****
  parser_state *PyParser_New(grammar *g, int start);
  void PyParser_Delete(parser_state *ps);
! int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno);
  void PyGrammar_AddAccelerators(grammar *g);
  
--- 39,44 ----
  parser_state *PyParser_New(grammar *g, int start);
  void PyParser_Delete(parser_state *ps);
! int PyParser_AddToken(parser_state *ps, int type, char *str, int lineno,
!                       int *expected_ret);
  void PyGrammar_AddAccelerators(grammar *g);
  

Index: parsetok.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/parsetok.c,v
retrieving revision 2.21
retrieving revision 2.22
diff -C2 -r2.21 -r2.22
*** parsetok.c	2000/07/09 03:09:56	2.21
--- parsetok.c	2000/07/11 17:52:59	2.22
***************
*** 140,145 ****
  		str[len] = '\0';
  		if ((err_ret->error =
! 		     PyParser_AddToken(ps, (int)type, str,
! 				       tok->lineno)) != E_OK) {
  			if (err_ret->error != E_DONE)
  				PyMem_DEL(str);
--- 140,145 ----
  		str[len] = '\0';
  		if ((err_ret->error =
! 		     PyParser_AddToken(ps, (int)type, str, tok->lineno,
! 				       &(err_ret->expected))) != E_OK) {
  			if (err_ret->error != E_DONE)
  				PyMem_DEL(str);

Index: tokenizer.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Parser/tokenizer.c,v
retrieving revision 2.45
retrieving revision 2.46
diff -C2 -r2.45 -r2.46
*** tokenizer.c	2000/07/09 03:09:56	2.45
--- tokenizer.c	2000/07/11 17:52:59	2.46
***************
*** 413,423 ****
  {
  	if (tok->alterror) {
! 		tok->done = E_INDENT;
  		tok->cur = tok->inp;
  		return 1;
  	}
  	if (tok->altwarning) {
! 		PySys_WriteStderr("%s: inconsistent tab/space usage\n",
! 			tok->filename);
  		tok->altwarning = 0;
  	}
--- 413,423 ----
  {
  	if (tok->alterror) {
! 		tok->done = E_TABSPACE;
  		tok->cur = tok->inp;
  		return 1;
  	}
  	if (tok->altwarning) {
! 		PySys_WriteStderr("%s: inconsistent use of tabs and spaces "
!                                   "in indentation\n", tok->filename);
  		tok->altwarning = 0;
  	}
***************
*** 485,491 ****
  				/* Indent -- always one */
  				if (tok->indent+1 >= MAXINDENT) {
! 					PySys_WriteStderr(
! 						"excessive indent\n");
! 					tok->done = E_TOKEN;
  					tok->cur = tok->inp;
  					return ERRORTOKEN;
--- 485,489 ----
  				/* Indent -- always one */
  				if (tok->indent+1 >= MAXINDENT) {
! 					tok->done = E_TOODEEP;
  					tok->cur = tok->inp;
  					return ERRORTOKEN;
***************
*** 507,513 ****
  				}
  				if (col != tok->indstack[tok->indent]) {
! 					PySys_WriteStderr(
! 						"inconsistent dedent\n");
! 					tok->done = E_TOKEN;
  					tok->cur = tok->inp;
  					return ERRORTOKEN;
--- 505,509 ----
  				}
  				if (col != tok->indstack[tok->indent]) {
! 					tok->done = E_DEDENT;
  					tok->cur = tok->inp;
  					return ERRORTOKEN;




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4