Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llSay(0, (string)(2*3-1))

blaze Spinnaker
1/2 Serious
Join date: 12 Aug 2004
Posts: 5,898
09-03-2005 17:15
Object: 6


Evil! Pure pure evil!

Syntax error, I can handle, but this.. UGH.
_____________________
Taken from The last paragraph on pg. 16 of Cory Ondrejka's paper "Changing Realities: User Creation, Communication, and Innovation in Digital Worlds :

"User-created content takes the idea of leveraging player opinions a step further by allowing them to effectively prototype new ideas and features. Developers can then measure which new concepts most improve the products and incorporate them into the game in future patches."
Driftwood Nomad
Registered User
Join date: 10 May 2003
Posts: 451
09-03-2005 17:51
Hey, I've noticed I usually get a syntax error with something like that. I end up having to put spaces before and after the minus sign for it to compile.

But still....yikes
_____________________
Driftwood Nomad
D&D Dogs Co-founder

"Second Life’s first AI companion animal"
The Second Opinion, 08/05/2003

D&D Dogs HQ Pawaii (127, 63)
Mainland Store Kuula (214, 124)

http://www.sldogs.com

SL Dogs Zazzle store!
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
09-03-2005 17:54
***Prays for C***

This is a fundamental flaw that indicates how young this language is. Oh please, Lindens, please just give me assembly...
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-03-2005 19:05
Um... so why's it doing that? Didn't hande the parentheses correctly, returned the temp variable from the 2*3 to the typecast?
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
09-03-2005 19:20
LSL vomits on the '-'. It parses them very badly.
Ziggy Puff
Registered User
Join date: 15 Jul 2005
Posts: 1,143
09-03-2005 19:22
Weird. Thanks :)
Jillian Callahan
Rotary-winged Neko Girl
Join date: 24 Jun 2004
Posts: 3,766
09-03-2005 19:42
Yeah. For now, always add spces between numbers and operators. It gets it right if you put in spaces. Poor, poor lil parser. It's drain brammaged.
_____________________
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
09-03-2005 23:40
Its a problem in how integers are recognized during the tokenizing faze of the compiler.

If LL wanted to fix it they would have to change the stuff below in the lex file

The trouble is in the recognition. {D} eats both on number and a sign, which they should only look for a sign once.

CODE

E [Ee][+-]?{D}+
...
{D}+ { yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); }
...
{D}+{E} { yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
{D}*"."{D}+({E})?{FS}? { yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
{D}+"."{D}*({E})?{FS}? { yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }


CODE

E [Ee][+-]?{N}+
...
[-]?{N}+ { yylval.ival = strtoul(yytext, NULL, 10); return(INTEGER_CONSTANT); }
...
[-]?{N}+{E} { yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
[-]?{N}*"."{N}+({E})?{FS}? { yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
[-]?{N}+"."{N}*({E})?{FS}? { yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); }
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
Minsk Oud
Registered User
Join date: 12 Jul 2005
Posts: 85
09-04-2005 11:45
Beautiful, beautiful... I missed that completely when reading their grammar.

For anyone who is not a lex nerd, these bugs mean that: "3-1", "3.-5", "3-5.2", "3-5.-2" and similar will be parsed as single numbers. strtoul as used and atof only consume values until they hit an illegal character (and do not actually report error), so the first example will be an integer three, and the remainder will be floating-point threes.

The moral of the story being to properly space your code so a human can read it, because testing parsers is not exactly trivial (ran the course project and watched a hundred or so undergrads suffer through it, so believe me).

------

If any of the LL devs feel lazy, the following code block is hereby placed in the public domain (if it were actually copyrightable in the first place):

CODE

OCT 0[0-8]+
HEX 0[xX][0-9a-fA-F]+
DEC [-+]?[0-9]+
EXP [eE]{DEC}

{OCT} |
{DEC} |
{HEX} {}

{DEC}{EXP} |
"."[0-9]+{EXP}? |
{DEC}"."[0-9]*{EXP}? {}


Need to add the {FS}? and check the floating point rules, though I am pretty sure they are equivalent. Happened have it lying around here, so does not cost me anything.
_____________________
Ignorance is fleeting, but stupidity is forever. Ego, similar.
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
09-04-2005 15:49
You should post that to the hotline. I think they could probably stick that into the Preview client without much difficulty.