ConsenSysMesh / solidity-parser

Solidity Parser in Javascript
137 stars 53 forks source link

RBrace (ASCII 0x7D) in strings breaks parser #59

Closed christoph2806 closed 7 years ago

christoph2806 commented 7 years ago

truffle (which uses this parser) does (of course) compile this:

pragma solidity ^0.4.7;
contract dont_care {

    function test () {
        string memory x = "x";
    }
}

but not this:

pragma solidity ^0.4.7;
contract drives_me_nuts {
    function test () {
        string memory x = "}";
    }
}

Parser output:

$ truffle compile

/usr/local/lib/node_modules/truffle/node_modules/solidity-parser/index.js:39
      throw e;
      ^
SyntaxError: Expected "contract", "import", "library", "pragma", "using", comment, end of input, end of line or whitespace but "}" found. Line: 24, Column: 1
    at peg$buildException (/usr/local/lib/node_modules/truffle/node_modules/solidity-parser/build/imports_parser.js:487:14)
    at Object.peg$parse [as parse] (/usr/local/lib/node_modules/truffle/node_modules/solidity-parser/build/imports_parser.js:4080:13)
    at Object.parse (/usr/local/lib/node_modules/truffle/node_modules/solidity-parser/index.js:34:23)
    at /usr/local/lib/node_modules/truffle/lib/profiler.js:134:36
    at tryToString (fs.js:455:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)

@raineorshine

christoph2806 commented 7 years ago

38 already closed. you can close this one as well. Sorry, didn't notice it had been fixed already. Is still open in truffle however.