refactor($parse): add lgalfaso's refactors and suggestions

@lgalfaso's PR #7543 had two aspects of it that I didn't include in my last changes to $parse (#7552, #7555)

* Lexer should only take care of `constant`, and the Parser should deduce that a _primary_ `constant` is also a `literal`
* Simplify the logic of Parser.filter