New option: "curly"

Mar 5, 2010 at 3:59 AM

Below are updates to wsh.js for an option to not require {}'s on blocks. I called the new option "curly". I'm not sure the best way to post it, so here it goes:

 

        allOptions = {
            adsafe     : true, // if use of some browser features should be restricted
            bitwise    : true, // if bitwise operators should not be allowed
            browser    : true, // if the standard browser globals should be predefined
            cap        : true, // if upper case HTML should be allowed
>>>         curly      : true, // if true require curly braces around block
            debug      : true, // if debugger statements should be allowed

--

block (1766):

        if (nexttoken.id === '{') {
            ...
        } else {
>>>
            if (option.curly)
                warning("Expected '{a}' and instead saw '{b}'.",
                        nexttoken, '{', nexttoken.value);
            noreach = true;
            if (token.line === nexttoken.line)
                a = [statement()];
            else {
                indent += 4;
                a = [statement()];
                indent -= 4;
                if (nexttoken.id === '}')
                    indent -= 4;
                indentation();
            }
<<<
            noreach = false;
        }