rev 264 - in trunk: pr src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-04-03 00:35:04 -0500 (Sat, 03 Apr 2004)
New Revision: 264
Modified:
trunk/pr/test.pr
trunk/src/prothon.y
Log:
turn off indent error checking on blank lines
Modified: trunk/pr/test.pr
===================================================================
--- trunk/pr/test.pr 2004-04-03 04:02:28 UTC (rev 263)
+++ trunk/pr/test.pr 2004-04-03 05:35:04 UTC (rev 264)
@@ -1,11 +1,5 @@
#!/usr/local/bin/prothon
def x():
- x=1
- def y():
- y=1
- print 1
print 2
- ,44
-
-x()
+ ,44
Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y 2004-04-03 04:02:28 UTC (rev 263)
+++ trunk/src/prothon.y 2004-04-03 05:35:04 UTC (rev 264)
@@ -686,7 +686,7 @@
}
int yylex (YYSTYPE *lvalp, void* yylex_param){
- int c, indent_cnt=0, unknown_indent_flag=0, mixed_indents;
+ int c, indent_cnt=0, unknown_indent_flag=0, mixed_indents, level_mismatch;
if (state->indents_needed > 0){
state->indents_needed--;
@@ -728,6 +728,7 @@
}
if (c == '\n'){
int llen = clist_len(state->indent_stack);
+ level_mismatch = 0;
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)
@@ -744,19 +745,11 @@
} 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;
+ for (indent_cnt=0; chr_cnt > 0 && indent_cnt < llen; indent_cnt++)
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 (chr_cnt < 0)
+ level_mismatch = TRUE;
+ else if (chr_cnt) {
if (!state->last_line_colon) goto check_comment;
indent_cnt++;
clist_append_num(state->indent_stack, -chr_cnt);
@@ -776,6 +769,10 @@
}
}
ungetch(c, state);
+ if (level_mismatch) {
+ printf("Lexical error: indentation level does not match any previous level\n");
+ return ERR;
+ }
if (mixed_indents){
printf("Lexical error: mixed tabs and spaces in indentation\n");
return ERR;