 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Apr 02, 2008 10:00 am
[2.21] Script reformat causing breakage |
I pasted in some pseudocode to play around with to get a gcd function, but on the way the reformatter broke it...
I know the code below doesn't work, but it is at least properly properly bracketted. If you use the reformatter on it then it inserts an extra opening bracket for some reason.
| Code: |
#if (%mod( $a, $b) = 0) {#return {0, 1}}
{
{x, y} = gcd(b, %mod(a,b))
#return {y, x-y*(a div b)}
} |
Reformatting results in
| Code: |
#if (%mod( $a, $b) = 0) {#return {0, 1}}
{
{
{x, y} = gcd(b, %mod(a,b))
#return {y, x-y*(a div b)}
} |
If you keep on reformatting it then you get an extra { each time |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 02, 2008 4:57 pm |
The problem is the line:
{x, y} = gcd(b, %mod(a,b))
what are you trying to do with that? That is not valid CMUD syntax. The Reformatter only works properly if there are no syntax errors in your script. Check it for syntax errors first. I should probably force the Reformat command to do a Check Syntax first so that this kind of problem doesn't happen. |
|
|
|
 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Apr 02, 2008 7:42 pm |
Yep, I mentioned that I knew the syntax wasn't right yet, but it still seemed a bug that it'd insert an extra {
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
Zugg MASTER

Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Wed Apr 02, 2008 10:43 pm |
No, it's not a bug. If there is a syntax error, then the reformatter has no way to work properly. The reformatter relies upon the zScript parser, and if there is a parse error, then the results of a reformat are completely undefined. Like I said, the "fix" is to disable Reformat if there are any syntax errors. It's just impossible to write a reformatter that works properly when there are syntax errors. This is true of most any computer language and formatter.
|
|
|
|
 |
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Wed Apr 02, 2008 11:07 pm |
I understand that, maybe I should have said that it seemed to be weird that it was trying to reformat something that didn't make sense. So I agree, the fix is to stop it trying to reformat a broken script.
|
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
 |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|