I was entirely amazed by how Coq's parser is implemented. e.g.

https://softwarefoundations.cis.upenn.edu/lf-current/Imp.html#lab347

It's so crazy that the parser seems ok to take any lexeme by giving notation command and subsequent parser is able to parse any expression as it is. So what it means is the grammar must be context sensitive. But this is so flexible that it absolutely goes beyond my comprehension.

Any pointers on how this kind of parser is theoretically feasible? How should it work? Any materials or knowledge would work. I just try to learn about this type of parser in general. Thanks.

Please do not ask me to read Coq's source myself. I want to check the idea in general but not a specific implementation.