Forum
Small brackets-parsing glitch (*solved*) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Small brackets-parsing glitch (*solved*) (/showthread.php?tid=315)



Small brackets-parsing glitch (*solved*) - LTee - 02-23-2011

Messing around with some of my other code over lunchtime with the latest beta (2100), I discovered a small error when parsing brackets.

Take a look at this code:
Code:
DIM test(10, 10) as UBYTE
DIM x as UBYTE
DIM y as UBYTE

x = 5
y = 5

PRINT test(x - 1, y)
PRINT test((x - 1), y)
PRINT test(x, y - 1)
PRINT test(x, (y - 1))

The final PRINT statement will not compile unless you remove the brackets from around the (y - 1). Strangely, the brackets seem to be okay if we're dealing with the first dimension of the array (so it's okay to have 'x - 1' in brackets), just not for the second. :-)


Re: Small brackets-parsing glitch - LTee - 02-23-2011

Whoops, I forgot to mention that the compile error is this:
Code:
Error: syntax error. Unexpected token '(' [LLP]



Re: Small brackets-parsing glitch - boriel - 02-23-2011

LTee Wrote:Whoops, I forgot to mention that the compile error is this:
Code:
Error: syntax error. Unexpected token '(' [LLP]
OMG! Confusedhock: This is going to be the new preprocessor (what a nightmare!) :mrgreen:
Try filtering it throug zxbpp:
Code:
zxbpp yourprogram.bas
The filtered program will be printed in the screen (stdout). If no error is given, then it's in the compiler parser.
Update: Confirmed. It's the preprocessor :x :roll:


Re: Small brackets-parsing glitch - LTee - 02-23-2011

Oops! Sorry! :-D


Re: Small brackets-parsing glitch - boriel - 02-23-2011

Ok, seems to be fixed.
As always, download 1.2.7-r2103 from here: <!-- m --><a class="postlink" href="http://www.boriel.com/wiki/en/index.php/ZX_BASIC:Archive">http://www.boriel.com/wiki/en/index.php ... IC:Archive</a><!-- m -->


Re: Small brackets-parsing glitch - LTee - 02-24-2011

That seems to have done the trick, boriel - code's compiling and running normally now!

Many thanks, as usual! Smile