[sldev] Any lex & yacc gurus? Looking at VWR-68

Dzonatas dzonatas at dzonux.net
Thu Jun 14 17:49:21 PDT 2007


Sounds like it does a read-ahead and parse before the left-to-right 
tokenization. Quick answer: precedence.

Tweak the precedence. Split some of the lines in two or more. You want 
it to see scalars before operators, but allow for the unaries to be 
parsed under the scalars.

Soft Linden wrote:
> A lot of ya know we're busily catching up on old patches. Sorry this
> took as long as it did. :(
>
> One that's got me a bit stumped at the moment is VWR-68:
> https://jira.secondlife.com/browse/VWR-68
>
> The patched grammar properly takes care of the following:
>
> integer i;
> integer x = 5;
>
> for( i = 0; i < x-1; i++ ) // SYNTAX ERROR
>    llOwnerSay( (string)i );
>
> The above gives a syntax error in current LSL scripts because the
> grammar greedily parses -1 as a constant, netting the token sequence
> "variable constant" instead of "variable operator constant." The new
> grammar fixes that.
>
> Unfortunately, the patched grammar is now too greedy when it tries to
> fold constant expressions:
>
> x = x - 5 - 5; // becomes x = x - (5-5) becomes x = x - 0
>
> I haven't played with lex and yacc in ages. My initial inclination was
> to try the alternate fix of knocking '-' off the choice of D tokens in
> the unpatched lex and changing the yacc file to make '-' a unary
> operator instead of an optional constant integer prefix as it is in
> Argent's patch. But this would break initialization of negative global
> constants unless I hack the assignment operator to explicitly parse
> negative assignments. That's a gross hack. :/
>
> Any chance a refinement to VWR-68 is a shallow problem for anyone on 
> the list?
> _______________________________________________
> Click here to unsubscribe or manage your list subscription:
> /index.html
>
>

-- 
Power to Change the Void


More information about the SLDev mailing list