Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit a02e8ae

Browse files
committed
Fix for issue #45.
When the parser does not recognize a particular syntax, it gobbles up a symbol and tries to pick up from there. It should make an exception for "}" closing a compound statement, however. Otherwise, it may mix up global & local levels.
1 parent 70eee50 commit a02e8ae

File tree

4 files changed

+88
-15
lines changed

4 files changed

+88
-15
lines changed

compiler/sc1.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,7 +890,9 @@ int pc_compile(int argc, char *argv[])
890890
pc_printf("\n%d Warning%s.\n",warnnum,(warnnum>1) ? "s" : "");
891891
retcode=0; /* use "0", so that MAKE and similar tools continue */
892892
} else {
893-
retcode=jmpcode;
893+
if (verbosity>0)
894+
pc_printf("Completed successfully\n");
895+
retcode = jmpcode;
894896
} /* if */
895897
#if defined __LINUX__ || defined __FreeBSD__ || defined __OpenBSD__
896898
br_deinit();
@@ -1650,7 +1652,7 @@ static void about(void)
16501652
pc_printf(" 1 core instruction set (JIT-compatible)\n");
16511653
pc_printf(" 2 supplemental instruction set\n");
16521654
pc_printf(" 3 full instruction set (packed opcodes)\n");
1653-
pc_printf(" -p<name> set name of the \"prefix\" file\n");
1655+
pc_printf(" -p<name> set the \"prefix\" file; omit name to block default prefix file\n");
16541656
#if !defined PAWN_LIGHT
16551657
pc_printf(" -r[name] write cross reference report to console or to specified file\n");
16561658
#endif

compiler/sc3.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2104,6 +2104,11 @@ static int primary(value *lval,int *symtok)
21042104
if (constant(lval)==0) {
21052105
error(29); /* expression error, assumed 0 */
21062106
ldconst(0,sPRI); /* load 0 */
2107+
/* Normally, gobble up unrecognized symbols, but make an exception for '}',
2108+
* because it closes compound statements.
2109+
*/
2110+
if (*symtok=='}')
2111+
lexpush();
21072112
} /* if */
21082113
return FALSE; /* return 0 for constants (or errors) */
21092114
}

test/issue45.p

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
operator=(Tag:x)
2+
{
3+
return _:x:
4+
}
5+
6+
main()
7+
{
8+
new a = Tag:5;
9+
printf("%d", a);
10+
}

0 commit comments

Comments
 (0)