rev 263 - in trunk: pr src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: mark
Date: 2004-04-02 23:02:28 -0500 (Fri, 02 Apr 2004)
New Revision: 263

Modified:
   trunk/pr/test.pr
   trunk/src/prothon.y
Log:
indent changes now in prothon.y where they belong

Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr	2004-04-03 03:39:30 UTC (rev 262)
+++ trunk/pr/test.pr	2004-04-03 04:02:28 UTC (rev 263)
@@ -1,15 +1,11 @@
 #!/usr/local/bin/prothon
 
-Point = Object()
-with Point:
-	.x0 = 0
-	def .__init__():
-			print 'x:', (33*2
-   +7+3)
-			print 'ok'
-p1 = Point()
-p2 = Point()
-print 'Point.x0',Point.x0
-print 'p1.x0',p1.x0
-print 'p2.x0',p2.x0
+def x():
+	x=1
+	def y():
+		y=1
+		print 1
+	print 2
+		   ,44
 
+x()

Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y	2004-04-03 03:39:30 UTC (rev 262)
+++ trunk/src/prothon.y	2004-04-03 04:02:28 UTC (rev 263)
@@ -726,78 +726,78 @@
 			else
 				ungetch(c2, state);
 		}
-		if (c == '\n'){
-			int llen = clist_len(state->indent_stack);
-			unknown_indent_flag = 0; 
-			// if a ( { or [ is on top of indent stack then this is a continuation line
-			if (clist_len(state->indent_stack) && clist_tos_num(state->indent_stack) > 0)
-				continue;
-			if (!state->indent_char) {
-				if ((c=getch(state)) == '\t' || c == ' ') {
-					int new_chr_cnt = 1;
-					while ((c=getch(state)) == c) new_chr_cnt++;
-					if (!state->last_line_colon) continue;
-					state->indent_char = c;
-					clist_append_num(state->indent_stack, -new_chr_cnt);
-					indent_cnt = 1;
-				}
-			} else {
-				int i, chr_cnt;
-				for(chr_cnt=0; (c=getch(state)) == state->indent_char; chr_cnt++) ;
-				indent_cnt = 0;
-				for (i=0; i < llen; i++) {
-					if (chr_cnt < 0) {
-						printf("Lexical error: indentation level does not match any previous level\n");
-						return ERR;
-					}
-					if (chr_cnt == 0) {
-						indent_cnt = i;
-						break;
-					}
-					chr_cnt -= -clist_num(state->indent_stack, i);
-				}
-				if (chr_cnt)  {
-					if (!state->last_line_colon) continue;
-					indent_cnt++;
-					clist_append_num(state->indent_stack, -chr_cnt);
-				}
-			}
-			mixed_indents = ( (state->indent_char == '\t' && c == ' ') ||
-						      (state->indent_char == ' '  && c == '\t')  );
-			while (c == ' ' || c == '\t') c = getch(state);
-			if (c == '\n' || c == '#')
-				goto check_comment;
-			if (c == '/') {
-				int c2=getch(state);
-				ungetch(c2, state);
-				if (c2 == '*'){
-					unknown_indent_flag = 1;
-					goto check_comment;	
-				}
-			}
-			ungetch(c, state);
-			if (mixed_indents){
-				printf("Lexical error: mixed tabs and spaces in indentation\n");
-				return ERR;
-			}
-			state->indents_needed = indent_cnt - state->old_tab_count;
-			state->old_tab_count = indent_cnt;
-			while (clist_len(state->indent_stack) > indent_cnt) clist_pop(state->indent_stack);
-			return EOL;			
-		}
-		break;
-	}
-	if (c == EOF){
-		if (state->old_tab_count) {
-			state->indents_needed = 0 - state->old_tab_count;
-			state->old_tab_count  = 0;
-			return EOL;
-		} else if (!state->eof_flag) {
-			state->eof_flag = 1;
-			return EOL;
-		} else
-			return 0;   // EOF
-	}
+		if (c == '\n'){
+			int llen = clist_len(state->indent_stack);
+			unknown_indent_flag = 0; 
+			// if a ( { or [ is on top of indent stack then this is a continuation line
+			if (clist_len(state->indent_stack) && clist_tos_num(state->indent_stack) > 0)
+				continue;
+			if (!state->indent_char) {
+				if ((c=getch(state)) == '\t' || c == ' ') {
+					int tmp_indent_char = c, new_chr_cnt = 1;
+					while ((c=getch(state)) == tmp_indent_char) new_chr_cnt++;
+					if (!state->last_line_colon) goto check_comment;
+					state->indent_char = tmp_indent_char;
+					clist_append_num(state->indent_stack, -new_chr_cnt);
+					indent_cnt = 1;
+				}
+			} else {
+				int chr_cnt;
+				for(chr_cnt=0; (c=getch(state)) == state->indent_char; chr_cnt++) ;
+				for (indent_cnt=0; indent_cnt < llen; indent_cnt++) {
+					if (chr_cnt < 0) {
+						printf("Lexical error: indentation level does not match any previous level\n");
+						return ERR;
+					}
+					if (chr_cnt == 0) break;
+					chr_cnt -= -clist_num(state->indent_stack, indent_cnt);
+				}
+				if (chr_cnt < 0) {
+					printf("Lexical error: indentation level does not match any previous level\n");
+					return ERR;
+				}
+				if (chr_cnt)  {
+					if (!state->last_line_colon) goto check_comment;
+					indent_cnt++;
+					clist_append_num(state->indent_stack, -chr_cnt);
+				}
+			}
+			mixed_indents = ( (state->indent_char == '\t' && c == ' ') ||
+						      (state->indent_char == ' '  && c == '\t')  );
+			while (c == ' ' || c == '\t') c = getch(state);
+			if (c == '\n' || c == '#')
+				goto check_comment;
+			if (c == '/') {
+				int c2=getch(state);
+				ungetch(c2, state);
+				if (c2 == '*'){
+					unknown_indent_flag = 1;
+					goto check_comment;	
+				}
+			}
+			ungetch(c, state);
+			if (mixed_indents){
+				printf("Lexical error: mixed tabs and spaces in indentation\n");
+				return ERR;
+			}
+			state->indents_needed = indent_cnt - state->old_tab_count;
+			state->old_tab_count = indent_cnt;
+			while (clist_len(state->indent_stack) > indent_cnt) clist_pop(state->indent_stack);
+			return EOL;			
+		}
+		break;
+	}
+	if (c == EOF){
+		if (state->old_tab_count) {
+			state->indents_needed = 0 - state->old_tab_count;
+			state->old_tab_count  = 0;
+			return EOL;
+		} else if (!state->eof_flag) {
+			state->eof_flag = 1;
+			return EOL;
+		} else
+			return 0;   // EOF
+	}
 	if (unknown_indent_flag) {
 		printf("Lexical error: Inline quote not allowed at beginning of indented line\n");
 		return ERR;
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.