Why is the parser needed

For any serious language, a parser is an essential tool that would allow developers to interact with files written in that language in order to pre-process or develop tools around them, and solidity is no exemption.

Examples such as retrieve all functions in a Contract, get all imports from a file, create inheritance graph, analyze code, determine compiler version needed, or even check if a file is a valid syntax is usually helpful for users, but most importantly, it is required for tools that improve the developing experience.

Current state and alternatives

Solidity is a really early and fast moving language. There has been at least one major update with breaking changes per year in its release schedule. Only in the last 3 months there has been multiple new keywords added right by the side of features such as interface inheritance, which can change drastically how a parser should work.

For this reason, and the fact that the team at solidity would rather move the development of the compiler fast to keep up with the developers needs, there has not been a formal definition of the solidity grammar, everything was inferred on what the compiler could parse.

There was a formal grammar and parser defined by @federicoBond, however this is not only not supported by the main solidity team, but also has not seen any changes in 7 months, time in which the solidity language has drastically changed.

solidityj/solidity-antlr4

federicobond/solidity-parser-antlr

It seems like Consensys has taken support of this grammar, as well as the parser. This parser is more closely up to date with the current solc version, but is still behind the same, meaning projects using the latest solidity version could not make user of these tools, making adopting new changes and moving forward take more time.

ConsenSys/solidity-antlr4

ConsenSys/solidity-parser-antlr

Just recently, the solidity team agreed to take include the antlr4 into their sourceCode

ethereum/solidity

There is also a python version of the parser that will allow its use outside the javascript environment. Note that none of these solutions are standalone.

ConsenSys/python-solidity-parser