|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ /* * LexDiff.java * * Created on 09 December 2003, 16:34 */ package org.netbeans.jmi.javamodel.regenerator; import java.io.File; import java.io.FileReader; import org.netbeans.junit.diff.Diff; import org.netbeans.lib.java.parser.Factory; /** * * @author jb105785 */ public class LexDiff implements Diff { public boolean diff(String str, String str1, String str2) throws java.io.IOException { return diff(new File(str), new File(str1), null); } public boolean diff(java.io.File file, java.io.File file1, java.io.File file2) throws java.io.IOException { org.netbeans.lib.java.parser.JScanner lex1 = Factory.getDefault().getScanner(new FileReader(file), "pending"); org.netbeans.lib.java.parser.JScanner lex2 = Factory.getDefault().getScanner(new FileReader(file1), "pending"); int token1 = lex1.yylex(); int token2 = lex2.yylex(); while (token1 != 0 && token2 !=0 ){ if (token1 != token2) { System.out.println("token " + token1 + " (" + lex1.yytext() + ") != " + token2 + " (" + lex2.yytext() + ")" ); return true; } if (!lex1.yytext().equals(lex2.yytext())) { System.out.println("token " + token1 + " (" + lex1.yytext() + ") != " + token2 + " (" + lex2.yytext() + ")" ); return true; } token1 = lex1.yylex(); token2 = lex2.yylex(); } if (token1 != token2) { System.out.println("token " + token1 + " (" + lex1.yytext() + ") != " + token2 + " (" + lex2.yytext() + ")" ); return true; } return false; } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.