java - How can I keep track of original character positions in a string across transformations? -


I am working on an anti-literary program for my CS class. It involves detecting plagiarism in computer science courses (programming assignment)

Basically, I am taking a group of programming work. Explains that one of the assignments looks like this:

  Public class Myclass {public static zero main (string [] args) {// some variables some somear = 0; }}  

It needs to be run through a front-end, lexical analysis section, which is to break the features of code that we do not want. In this example, I want to change the name of all identifier name for continuous "V" and strip all comments from the code.

To do this, we will use the existing grammar to use the appropriate languages ​​for different languages.

The end result is:

  public class V {public static zero V (string [] v) {int v = 0; }}  

Print all the spaces to get us again:

  publicclassV {publicstaticvoidV (string [] v) {intV = 0;} }  

This string then breaks down in the pre-sized KGram. For example, K = 5 (in reality this would be larger):

  public public blicc liccl iccla ... = 0;}}  

here The problem is:

Each KGram is washed with the rolling hash function and should be entered in the source text with their original character status . A Kashmir-village hash and character status make a fingerprint.

How can I track the status of a KG-grade in the source text in all the front gaps of identity cards, comments and white space?

It is necessary to final stage of the program where you match the pairs of documents in the original source text. In order to highlight KG-Hash matches, I need to know that the beginning of the gram-chak in the original source has started and ended.

Keep track of token states in the ANTLR Lexers source stream.

  • Take notes and white in hidden hidden channels
  • Set the property of the identifier token for "V"
  • Run your rolling hash against> normal token stream , looking at property of text of each token.

With tokens from the beginning to the end, you will have mapping protected as well.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -