I am writing a simple parser for C. I just ran it with some other language files (for fun - to see the degree of C-similarity and laziness - you do not want to write separate parsers for each language if I can avoid this).
However, the parser seems to break into JavaScript if the parsed code contains regular expressions ...
Case 1: For example, by analyzing a piece of JavaScript code,
var phone="(304)434-5454"
phone=phone.replace(/[\(\)-]/g, "")
//Returns "3044345454" (removes "(", ")", and "-")
"(", "[", etc., etc. are the same as starters of new areas that can never be closed.
Case 2: And, for the Perl code snippet,
$FILE_PATH =~ s@\\@//@g;
// match as a comment ...
How can I detect a regular expression in the text content of a "C-like" program-file?