Possible Duplicate:
Detecting programming language from a snippet
Is there a way to identify the following for a text snippet?
- Whether it is a piece of code
- The programming language in which it is written
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Depends on how long is the code snippet, for extremely short code sample it may not be possible at all, and still not easy for long code snippets.
But anything that is developed for this purpose cannot ensure 100% accuracy of detecting the programming language for any length of code snippet (except if everything in the language is in the code snippet).
A lot of the programming languages is similar. One very accurate (not 100% though) is to look for the header files or libraries etc that are included in the code, and how they are added (using, #include etc), it can be a huge and very accurate hint about the programming language.