Parser generation

旧巷老猫 提交于 2019-12-04 07:07:32

问题


i am doing a project on SOFWARE PLAGIARISM DETECTION..i am intended to do it with language C..for that i am supposed to create a token generator, and a parser..but i dont know where to start..any one can help me out with this..

i created a database of tokens and i separated the tokens from my program.Next thing i wanna do is to compare two programs to find out whether it's plagiarized or not. For that i need to create a syntax analyzer.I don't know where to start from...

i.e I want to create a parser for c programs in python


回答1:


If you want to create a parser in Python you can look at these libraries:
PLY
pyparsing
and Lepl - new but very powerful




回答2:


Building a real C parser by yourself is a really big task.

I suggest you either find one that is already done, eg. pycparser or you define a really simple subset of C that is easily parsed.

You'll have plenty of work to do for your plagiarism detector after you are done parsing C.




回答3:


I'm not sure you need to parse the token stream to detect the features you're looking for. In fact, it's probably going to complicate things more than anything.

what you're really looking for is sequences of original source code that have a very strong similarity with a suspect sample code being tested. This sounds very similar to the purpose of a Bayes classifier, like those used in spam filtering and language detection.



来源:https://stackoverflow.com/questions/3976665/parser-generation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!