Java lexic analyzer [developed using Java, and used to analyze Java source files] January 12, 2003
1. Development Tools: Rational Rose2002 Jedition, Borland JBuilder6 Professional2. Development Steps: 1) The compiler principle based on the state conversion graph is as follows:
2) Set the analyzer model frame in ROSE, according to the status conversion graph algorithm and algorithm structure of the analyzer. The frame structure of the lexical analyzer is shown below:
(Analyzer Software Pack) (the controller structure of the lexical analyzer, including the precompiler, scanner, reserved words, and the type of words for words, and guidance procedures and control procedures for the lexical analyzer) (lexical analyzer) Scan buffer and input buffer structure and the buffer factory for the buffer) 3) Generate a Java frame code using ROSE forward engineering, editing the function code in JBuilder, generates the final code, perform TEST and DEBUG, final formation Target program. Please refer to the source code for specific implementation. Edit and test as shown below:
(Development environment) (operation results, detailed results attached back) 3. Source code: // lisence head / * java accountance analyyser ** Author Yellowicq ** all copyright reserved ** version 1.0 * /// lisence1) Leader analyzer Boot file: main.javaPackage JaccideNCeanalyse; import javax.xml.parsers. *; Import org.w3c.dom. *;
Public class main {
/ ** * @Param args * @Return Void * @Roseuid 3D9bae4702ad * / public static void main (String [] args) {// read configuration file, get system properties string cfgstring [] = new string [4]; TRY {Cfgstring = main.loadAAcfg ("d: //aacfg.xml");} catch (exception e) {E.PrintStackTrace (System.err);} // Set the file name // Reserved Word table file String ReserveFileName = cfgstring [0]; // Type Code Table File String ClassFileName = cfgstring [1]; // Need Analysis Source File String SourceFileName = cfgstring [2]; // Output file string OutputFileName = cfgstring [3]; / / Create a lexical analyzer AccidentAnAalySer AA = New AccidentAnalySer (); aa.setfilespath (ReserveFileName, OutputFileName); // Established the required file object // Initial Analysis Aa.initaa (); // Initialization Key Word table aa.keywordTable.initKeywordTable (); // Initialization Type Clicker table aa.classIdentity.initclassIdentityTable (); // Start lexical analysis aa.startaa (); // analysis
// Read Profile Private Static String [] loading {string cfgstring [] = new string [4]; / * Resolution XML configuration file * / try {/ * Create a document factory * / DocumentBuilderFactory Factory = DocumentBuilderFactory.newInstance (); / * create a document parser * / DocumentBuilder builder = factory.newDocumentBuilder (); / * parse the configuration file * / document doc = builder.parse (name); / * standardized documentation * / doc.normalize ( ); / * Find contact table * / nodelist nlists = doc.getElementsBytagname ("filepath"); for (int i = 0; i Package jaccidenceanalyse; Import java.io. *; import java.util. *; import jaccideanalyse.buffer. *; public class AccidenceAnalyser {private java.io.File SourceFile; private java.io.File ReserveFile; private java.io.File ClassFile; private java.io.File OutputFile; public Pretreatment pretreatment; public KeyWordTable keyWordTable; public ClassIdentity classIdentity; public Scaner ScaNer; Public ConcreteScanBufferFactory CSBFActory; / ** * @Roseuid 3D9BB93303D0 * / Public Accident AnAnalySer () {System.out.println ("[Infor] has established a lexical analyzer!");} / ** * @ROSEUID 3D9BAEF9029F * / public void initaa () {// Create buffer factory this.csbFactory = new concretescanBufferFactory (); // Create string scanned object scaner = new scaner (this); // Create a pre-handling object pretreatment = new Pretreatment (SourceFile, this); // create a keyword table object keyWordTable = new KeyWordTable (ReserveFile); // create the object code table object types do not classIdentity = new ClassIdentity (ClassFile); System.out.println ( "[ Infor] has been initialized by the character analyzer! "); / ** * @roseuid 3D9BAF12022D * / public void setFilesPath (String reserveFileName, String ClassFileName, String sourceFileName, String outputFileName) {// Create a file object SourceFile = new java.io.File (sourceFileName); // Create a file object ReserveFile = New java.io.file (reserveFileName); // Create a file object classfile = new java.io.file (classFileName); // Create a file object OutputFile = new java.io.file (outputFileName); // If the file already exists, delete, then create a new file IF (outputfile.exists () {OutputFile.delete ();} try (} catch (exception e) {E.PrintStackTrace (SYSTEM .err);} Try {// Create file randomly read object java.io.randomaccessfile routputfile = new java.io.randomaccessfile (this. OutputFile, "rw"); // Tips ROUTPUTFILE.WRITE ("////// n ". getBytes ()); ROTPUTFILE.WRITE ((" // jaccidenceanalyser version getversion () "design by Yellowicq //// N"). getBytes ()); routputfile.write ("// java lexic analysis /// n ".getbytes ()); routputfile.write (" // Develop / N "using Java Language / N". GetBytes ()); ROTPUTFILE.WRITE ("/// n". GetBytes ()); ROUTPUTFILE. Write ("The result of the lexical analysis is as follows: / n" .GetBytes ()); // Turn off file stream routputfile.close ();} catch (exception e) {E.PrintStackTrace (system.err);}} / ** * @ROSEUID 3D9BAFAB0089 * / public void startAA () {// From pre-processed start lexical analysis this.pretreatment.startPretreatment (); / ** * @ROSEUID 3D9BB0B40383 * / Public void outputstring {// Put the analysis of the word = "/ n [first" this.pretreatment.fileRow "line] / n" OutputString Try {// Create file randomly read object java.io.randomaccessfile routputfile = new java.io.randomaccessfile (this. OutputFile, "rw"); // Move pointer to file end ROUTPUTFILE.SEEK (routputfile.length () ); // start appending! Routputfile.write (outputString.getbytes ()); // Turn off the file stream routputfile.close (); } Catch (exception e) {E.PrintStackTrace (System.err);} // Put the word result of the analysis to the terminal system.out.print (outputString);} / ** * @Roseuid 3D9BB0CE02C2 * / Public Void ControlThread ) {// Control Scanner Start Scan Scner.Controlthread (); // Get the version number public string getversion () {Return "1.0";}} 3) Premium subroutine: pretreatment.java // Source File: D: //jaccideanalyse//pretreatment.java Package jaccidenceanalyse; Import jaccideAnaly.buffer. *; import java.io. *; public class Pretreatment {private String tmpString; private String outputString; private int BUFFER_SIZE = 100; private AccidenceAnalyser aa; public InputBuffer inputBuffer; // Input Buffer - shared private java.io.File SourceFile; // file object private java.io .RandomAccessFile randomAFile; // file object random public static int fileRow = 0; / ** * @roseuid 3DAB7C530399 * / public Pretreatment (file SourceFile, AccidenceAnalyser aa) {try {this.SourceFile = SourceFile; this.randomAFile = new java. io.RandomAccessFile (this.SourceFile, "r");} catch (FileNotFoundException e) {e.printStackTrace (System.err);} this.aa = aa; inputBuffer = aa.csbFactory.createInputBuffer (BUFFER_SIZE); System.out .println ("[Infor] Preprocessor has been created!"); / ** * @Roseuid 3d9bafe20331 * / public void PutsourceToinBuffer (string tmputbuffer.data = tmpstring.tochararray (); / ** * @ROSEUID 3D9BB0400169 * / Public void PutfintoscBuffer (String FiltratedString) {aa.scaner.scanbuffer.data = filterratestring.tochararray ();} / ** * @roseuid 3D9BB05E00A4 * / public void controlThread () {int intLength; int resCounter = 0; String tmpString; String filtratedString; System.out.println ( "[INFOR] Start word analysis"); try {if (SourceFile .exists ()) {// file existing // read file content to buffer while (tmpstring = this.randomaFile.Readline ())! = null) { filerow; // split system.out.println "................. Begin Row" this.fileerow "..................... .. "); // Start this line analysis system.out.println (" [Infor] is being processed: " String.Valueof (filerow)); // Put into the input buffer this.putSourceToinBuffer (tmpstring); / / Handling String FiltratedString = this.FilTrateSource (this.inputbuffer.data); System.out.println ("[Infor] has been filtered sentence:" filterString); // Put into the scan buffer this.putFintoscBuffer (FiltratedString); Aa.Controlthread ();} system.out.println ("[Infor] analysis");} else {// file does not exist System.err.Println ("[Error] source file does not exist!");}} Catch (exception e) {E.PrintStackTrace (System.err);}} / ** * @ROSEUID 3D9BB07D0239 * / Public String FiltrateSource Char [] data) {string filtratestring = String.Valueof (data) .trim (); returnifthi / ** * @ROSEUID 3D9BB9350315 * / public void startpretreatment () {this.controlthread ();}} 4) Scan subroutine: scaner.java//source file: d: //jaccideanalyse//scaner.java Package jaccidenceanalyse; Import JaccideAnalys.Buffer. *; public class Scaner {public ScanBuffer scanBuffer; // scan buffer - shared private String finalAccidence; private AccidenceAnalyser aa; private int BUFFER_SIZE = 100; private String toDelString; private int senLength = 0; private char [] sentenceChar = new char [1000 ]; Private string token; private int index = 0; private string IdEntity = "identity"; private string Digit = "DIGIT"; private string word_error_inf = "found unrecognized words in this line, this line analysis is terminated ! ";" / ** * @ROSEUID 3D9BB9370213 * / public scaner AA) {this.aa = aa; initbuffer (); this.finalAcident = ""; system.out.println ("[" Infor] Scan processor has been created! ");} / ** * @Roseuid 3d9bb2860329 * / public string readfromBuffer (char [] data) {string Todelstring = String.Valueof (data); Return Todelstring;} / ** * @param tmpString * @return String * @roseuid 3D9BB2D5008D * / public String scan (String toDelString) {sentenceChar = toDelString.toCharArray (); this.senLength = sentenceChar.length; int i = 0; // word Analysis While (this.index <= this.sength) {// state0: this.token = ""; this.char = getBC (SENTENCECHAR); if (this.char == ';') {Break; // '; 'Indicates this line of end} // Enter status judgment Switch (this.char) {// judge lettercase' a ': Case' B ': Case' C ': Case' D ': Case' E ': Case' F ' : Case 'G': Case 'I': Case 'J': Case 'K': Case 'L': Case 'M': Case 'N': Case 'O': Case 'P' : Case 'q': Case 's': Case 'T': Case 'u': Case 'V': Case 'W': Case 'x': Case 'Y': Case 'Z' : Case 'a': Case 'C': Case 'D': Case 'E': Case 'F': Case 'G': Case 'H': Case 'I': Case 'J' : Case 'K': Case 'M': Case 'N': Case 'P': Case 'Q': Case 'R': Case 'S': Case 'T' : Case 'u': Case 'w': Case 'W': Case 'Y': Case 'Z': // do this.token = this.contact (token, char); // state1 char = this.getchar (SENTENCECHAR); while (this.isletter (char) || this.token = this.contact (this.token, char); char = this.getChar SENTENCECHAR);} this.retract (); // state2 if (aa.keywordtable.iskeyword (token) {this.finalAcident "[reserved Word]" this.returnaword (token) "/ n";} else {this.finalAlacident = this .finalaccident "[identifier]" this.returnaword (TOKEN) "[Size]" String.Valueof (Identity) "/ n";} // clear up token THIS.TOKEN = ""; // judge Ditital case '0': case '1': Case '2': Case '4': Case '5': Case '6': Case '7': Case '8': CASE '9': // do this.token = this.contact (token, char); // state3 char = this.getChar (SENTENCECHAR); while (this.Token = this.contact (token, char); char = this.getchar (Sentencechar);} this.retract () ; // state4 this.finalAcident = this.finalAcident "[Number]" this.returnaword (token) "[Size]" String.Valueof (aa.classidentity.findkey (Digit) "/ n" ; // Clear Up token this.token = ""; Break; CASE '=': // state5 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccident "[equal sign" this.returnaword (token) "[Size]" String.Valueof Aa.classIndentity.FindKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; break; case ' ': // state6 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccide "[plus]" this.returnaword (token) "[Size]" String.Valueof Aa.classIndentity.FindKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case '*': // state7 this.token = this.contact (token, char); char = this.getchar (SENTENCECHAR); // state8 if (char == '*') {this.token = this.contact (token, char) "This.finalAccide = this.finalaccide " [Passenger] " this.Returnaword (token) " [Size] " String.Valueof (String.Valueof (char))) "/ n";} // state9 else {this.finalaccide = this.finalaccident "[Multi-pass]" this.returnaword (token) "[Various code]" String.Valueof (aa.classIndentity.FindKey String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case ',': // state10 this.token = this.contact (token, char); this.finalAccide = this.finalaccident "[comma] this.returnaword (token) " [Size] " String.Valueof (AA .classidentity.findKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; case '(': // state11 this.token = this.contact (token, char); this.finalAccide = this.finalaccident "[左 括号] this.returnaWord (token) " [Size] " String.Valueof Aa.classIndentity.FindKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case ')': // state12 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccide "[right bracket]" this.returnaWord (token) "[Size]" String.Valueof Aa.classIndentity.FindKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case '{': // state13 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccident "[Left Big Note] this.Returnaword (Token) " [Size] String.Valueof (aa.classidentity.findKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case '}': // state14 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccide "[right bulk]" this.returnaword (token) "[Size] String.Valueof (aa.classidentity.findKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case '[': // state15 this.token = this.contact (token, char); this.finalAccide = this.finalaccident "[left bracket] this.returnaword (token) " [Size] String.Valueof (aa.classidentity.findkey (string.valueof (char))) "/ n"; // clear up token this.token = "; Case ']': // state16 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccide "[Right Brand]" this.returnaword (token) "[Size]" String.Valueof (aa.classidentity.findKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; Case '.': // state17 this.token = this.contact (token, char); this.finalAccide = this.finalAlaccide "[点号] this.returnaword (token) " [Size] " String.Valueof Aa.classIndentity.FindKey (String.Valueof (char))) "/ n"; // Clear Up token this.token = ""; Break; DEFAULT: // state18 this.token = this.contact (this.token, this.char); // Add an error message this.finalaccide = this.finalAlaccide "[error]" this.word_error_inf "" this.token "'" "/ n"; this.ast = false; // Clear Up token this.token = ""; break;} if (this.astate == false) {Break;} } Return this.finalaccide; / ** * @roseuid 3D9BB2E70260 * / public void controlThread () {this.toDelString = this.readFromBuffer (this.scanBuffer.Data); this.aa.outputAccidence (this.scan (this.toDelString)); // delimiter System.out.println ("................... End Row" aa.pretreatment.fileerow "............. ............ "); // End this line analysis // clear up the var this.index = 0; this.finalAccide =" "; this.astate = true; this.todelstring = ""; This.Senlength = 0; this.token = "";} / ** * @Param tmpstring * @Return string * @ROSEUID 3D9BB3FB037F * / public string returnaWord (String token) {return token;} / ** * @ROSEUID 3D9BB55502B4 * / public void initBuffer () {this.scanbuffer = aa.csbfactory.createscanbuffer (buffer_size);} // The following is the processing method of the character /// character method start ///// / ** * @Roseuid 3d9bb0b40383 * / public char getbc (char [] senencechar) {Try {while (Sentencechar [this.index]) = = ') {This.index ;} this.index ;} catch (java.lang.arrayindexoutofboundsexception e) {return'; '; // indicates that the line has ended} Return SENTENCECHAR [INDEX - 1];} / ** * @Roseuid 3d9bb0b40383 * / public char getchar (char [] seencechar) {next (); return snentenechar [this.index - 1];} / ** * @ROSEUID 3D9BB0B40383 * / public void next () {this.index ;} / ** * @ROSEUID 3D9BB0B40383 * / public boolean isletter (char letter) {return java.lang.Character.isletter (letter);} / ** * @roseuid 3D9BB0B40383 * / public boolean ISDIGIT (char letter) {return java.lang.Character.isDigit (letter);} / ** * @roseuid 3D9BB0B40383 * / public String CONTACT (String TOKEN, char CHAR) { String tmps = token string.valueof (char); token = tmps; return token;} / ** * @Roseuid 3d9bb0b40383 * / public boolean isreserve (string token) {return aa.keywordtable.iskeyword (token); / ** * @ROSEUID 3D9BB0B40383 * / Public void retract () {this.index ---;} /// character method end ////} 5) Table leaving table program: KeywordTable.java//source file: d : //JaccideNCeanalyse/keywordtable.java Package jaccidenceanalyse; Import java.util. *; import java.io. *; Public class keywordtable {private faciler kwhash; private file reservefile; private fileReader resfileReader; // Read file object private int Tmp_buffer_size = 30; / ** * @ROSEUID 3D9BB9390108 * / public keywordTable (java.io.file reservefile) {system.out.println ("[Infor] key list is created!"); This.reservefile = reservefile;} / ** * @Param INW * @Return Boolean * @Roseuid 3d9bae4702ad * / public boolean iskeyword (string inf) {string resword; // Find Hash Table for (ENUMERATION E = this.kwhash.Elements (); E.hasMoreElements ); {Resword = (string) E.NEXTELEMENT (); if (resword.equalsignorecase (inw)) {return true;}} return false; / ** * @roseuid 3D9BAE7303D3 * / public void initKeyWordTable () {KWHash = new Hashtable (); // create a hash table int intLength; char [] chrBuffer = new char [TMP_BUFFER_SIZE]; String resWord; int resCounter = 0; try {IF (reservefile.exists ()) {// file exists // Create a read file object resfileReader = new java.io.fileReader (reservefile); // read the file content to the Hash table while ((intLength = ResfileReader.Read (chrbuffer ))))! = -1) {rescounter ; // Fill in the Hash table resword = String.Valueof (chrbuffer) .trim (); system.out.println ("[Infor] Read keyword: [index:" rescounter "] [Value:" resword "]"); this.kwhash.put (Integer.tostring (rescounter), resword);} // Close the read file object resfileReader.close ();} else {// file is not There is system.rr.println ("[ERROR] reserved word file does not exist!");}} Catch (exception e) {E.PrintStackTrace (System.err);}}}} 6) Type Cipler: ClassIndentity. Java // source file: d: // jaccideAnalyse // KeywordTable .java Package jaccidenceanalyse; Import java.util. *; import java.io. *; Public class classidentity {private facilentity; private file classfile; private fileReader classfileRead; // read file object private int TMP_Buffer_size = 30; / ** * @ROSEUID 3D9BB9390108 * / public classidententity (java.io.file classfile) {system.out.println ("[Infor] type clicc code table has been created!"); This.classfile = ClassFile;} / ** * @ROSEUID 3D9BB0B40383 * / / / Find Type Code Public INT FindKey (String Classword) {Int Key; for (Enumeration E = this.classhash.keys (); E.hasMoreElements ();) {key = Integer.Parseint ((String) E.NEXTELEMENT ()); if ((String) this.classhash.get (Integer.tostring (key))). EqualsignoreCase (Classword)) {Return Key;}} Return -1; } / ** * @roseuid 3D9BAE7303D3 * / public void initClassIdentityTable () {ClassHash = new Hashtable (); // create a hash table int intLength; char [] chrBuffer = new char [TMP_BUFFER_SIZE]; String classWord; int classCounter = 0; Try {if (ClassFile.exists ()) {// file exists // Create a read file object classfileReader = new java.io.fileReader (classfile); // Read the content to the Hash table while ((intLength = ClassFileReader.read (chrbuffer))! = -1) {ClassCounter ; // Fill in the Hash table classword = String.Valueof (chrbuffer) .trim (); system.out. Println ("[Infor] Read Type Code: [Key:" ClassCounter "] [Value:" ClassWord "]"); this.classhash.put (Integer.toToString (ClassCounter), ClassWord; } // Close the read file object classfileReader.close ();} else {// file does not exist system.rr.println ("[ERROR] type coded file does not exist!");}} Catch (Exception E) {E .printstacktrace (system.err);}}} 7) Abstract scan buffer factory: bufferfactory.java (buffer object using abstract factory method mode) // source file: d: // jaccideAnalyse // buffer // bufferfactory. Java Package JaccideAnalySe.Buffer; Public interface bufferfactory { / ** * @return JAccidenceAnalyse.Buffer.ScanBuffer * @roseuid 3D9BB6F0003E * / public ScanBuffer createScanBuffer (int size); / ** * @return JAccidenceAnalyse.Buffer.InputBuffer * @roseuid 3D9BB7090062 * / public InputBuffer createInputBuffer (int size); } 8) Buffer Factory: ConcreteScanBufferFactory.java (Implement Abstract Factory) // Source File: D: //jaccideAnalyse//Buffer//ConcretescanBufferFactory.java Package JaccideAnalySe.Buffer; Public Class ConcretescanBufferFactory Implements BufferFactory { / ** * @Roseuid 3d9bba19006a * / public concretescanbufferfactory () {system.out.println ("[Infor] buffer factory has established!");} / ** * @return JAccidenceAnalyse.Buffer.ScanBuffer * @roseuid 3D9BAC01004E * / public ScanBuffer createScanBuffer (int size) {System.out.println ( "[INFOR] create the scan buffer!"); Return new ScanBuffer (size); } / ** * @return JAccidenceAnalyse.Buffer.InputBuffer * @roseuid 3D9BB6050267 * / public InputBuffer createInputBuffer (int size) {System.out.println ( "[INFOR] Create input buffer!"); Return new InputBuffer (size); }} 9) Buffer object abstraction interface: buffer.java//source file: d: //jaccideAnalyse//buffer//buffer.java Package JaccideAnalySe.Buffer; // Abstract Buffer InterfacePublic Interface Buffer {} 10) Input Buffer Object: InputBuffer.java//Source File: D: //jaccideNceanalyse//Buffer/inputBuffer.java Package JaccideAnalySe.Buffer; Import java.io. *; Public Class InputBuffer Implements Buffer {Public Char [] Data; / ** * @ROSEUID 3D9BBA1C0186 * / public inputbuffer (int size) {this.data = new char [size]; } 11) Scan buffer object: scanbuffer.java//source file: d: //jaccideNceanalyse//buffer/scanbuffer.javaPackage JaccideAlySe.buffer; Public Class Scanbuffer Implements Buffer {Public Char [] DATA / ** * @ROSEUID 3D9BBA1A0314 * / Public scanbuffer (int size) {this.data = new char [size]; } 12) Lord Analyzer Profile: AACFG.XML XML Version = "1.0" Standalone = "YES"?> [2nd line] [Reserved Word] PUBLIC [Reserved Word] Void [Identifier] AMETHOD [Variety] 1 [Left Bracket] ([Variety] 8 [Reserver] INT [Intraper] Value [ Code] 1 [Right Brand]) [Various Code] 9 [Left Big Bouth] {[Variety] 10 [Three Lines] [Reserved Word] System [Point]. [Size] 14 [Identifier ] OUT [Size] 1 [Click]. [Size] 14 [Identifier] Println [Value Code] 1 [Left Bracket] ([Size] 8 [Identifier] Value [Size ] 1 [Right Brand]) [Size] 9 [Chapter 4] [Right Big Brand]} [Size] 11 [5th line] [Reserved Word] PUBLIC [Reserved Word] Static [Reserved Word] Void [Identifier] Main [Size] 1 [Left Bracket] ([Size] 8 [Identifier] String [Symp Code] 1 [Left Brand] [[Variety] 12 [Right Brand]] [Variety] 13 [Identifier] Args [Size] 1 [Right Brand]) [Size] 9 [ Left Big Bouth] {[Size] 10 [Chapter 6] [Identifier] ACLASS [Size] 1 [Identifier] FOO [Size] 1 [Moral] = [Size] 3 [Reserved Word] New [Identifier] Aclass [species Notak] 1 [Zuo] ([Variety] 8 [Right Brand]) [Size] 9 [7th line] [Reserved Word] INT [INT] I [Variety] 1 [Moral] = [Variety Code] 3 [Number] 0 [Size] 2 [8th line] [Identifier] FOO [Size] 1 [Click]. [Size] 14 [Identifier] AMETHOD [Size] 1 [Left Bracket] ([Size] 8 [ Identifier] I [Variety] 1 [Right Brand]) [Size] 9 [9th line] [Identifier] i [variety code] 1 [equal sign] = [variety code] 3 [identifier] i [type code] 1 [plus] [variety code] 4 [ Numbers] 1 [Size] 2 [10th line] [Identifier] FOO [Size] 1 [Point number]. [Size] 14 [Identifier] AMETHOD [Variety] 1 [Left Bracket] ([Size] 8 [ Identifier] I [Variety] 1 [Right Brand]) [Size] 9 [11th line] [right braces]} [variety] 11 [12th line] [Right Big Brand]} [Size] 11 16) Running system display: jbuilder.Runtime D: /jbuilder6/jdk1.3.1/bin/javaw -classpath "f: / mybak_new / jbproject / jaccideanalyse / classes; d: /jbuilder7/lib/rowset.jar; D: /Jbuilder6/lib/xerces.jar;d:/JBUILDER6/JDK1.3.1/demo/jfc/java2d/java2demo.jar;d:/JBUILDER6/JDK1.3.1/jre/lib/i18n.jar;d:/JBuilder6/ JDK1.3.1 / jRE / lib / jaws.jar; d: /jbuilder6/jdk1.3.1/jre/lib/rt.jar; d: /jbuilder6/jdk1.3.1/jre/lib/sunrsign.jar; d: / jbuilder6 /jdk1.3.1/lib/dt.jar;d:/JBUILDER6/JDK1.3.1/lib/htmlconverter.jar;d:/JBUILDER6/JDK1.3.1/lib/tools.jar "jaccideAnalys.main [infor] has established lexical Analyzer! [Infor] Buffer Factory has been established! [Infor] Create a scan buffer! [Infor] Scan processor has been created! [Infor] Create an input buffer! [Infor] Preprocessor has been created! [Infor] key Word table has been created! [Infor] Type Cabcoulation table has been created! [Infor] Has initialized the word method! [INDEX: 1] [value: while] [Infor] Read keyword : [Index: 2] [Value: Do] [Infor] Read Keywords: [INDEX: 3] [Value: Public] [Infor] Read Keywords: [INDEX: 4] [Value: Class] [Infor] Read keyword: [index: 5] [value: static] [Infor] Read keyword: [INDEX: 6] [Value: new] [Infor] Read keywords: [INDEX: 7] [Value: void ] [Infor] Read Keywords: [INDEX: 8] [Value: INT] [Infor] Read Keywords: [INDEX: 9] [V Alue: do] [Infor] Read Keywords: [INDEX: 10] [Value: for] [Infor] Read Keywords: [INDEX: 11] [Value: INT] [Infor] Read Keywords: [Index : 12] [Value: System] [Infor] Read Type Code: [Key: 1] [Value: Identity] [Infor] Read Type Clicc: [Key: 2] [Value: Digit] [Infor ] Read the type of type code: [key: 3] [value: =] [Infor] Read type single code: [key: 4] [value: ] [INFOR] Read type code: [key: 5] [value: *] [Infor] Read type single code: [Key: 6] [value: **] [Infor] Read Types Code: [Key: 7] [value:,] [Infor] Read Type Code: [Key: 8] [Value: (] [Infor] Read Type Code: [Key: 9] [Value: ] [Infor] Read type code: [key: 10] [value: {] [INFOR] read type type code: [key: 11] [value:}] [Infor] Read Types Code: [Key: 12] [value: [] [Infor] Read type single code: [key: 13] [value:]] [INFOR] Read type Code: [KEY: 14] [Value: .] [Infor] start word analysis ................. Begin Row 1 .................. ... [Infor] is being processed: 1 [Infor] has been filtered sentence: public class aclass {[1st line] [Reserved Word] Public [Reserved Word] Class [Identifier] ACLASS [Size] 1 [Left Big brackets] {[variety] 10 ...................... ........................ Begin Row 2 ..................... .. [Infor] is being processed: 2 [Infor] Filtered sentence: public void amethod (int value) { [2nd line] [Reserved Word] PUBLIC [Reserved Word] Void [Identifier] AMETHOD [Variety] 1 [Left Bracket] ([Variety] 8 [Reserver] INT [Intraper] Value [ Code] 1 [Right Brand]) [Various Code] 9 [Left Big Bouth] {[Variety] 10 ............................. End row 2 .. .......................................... Begin Row 3 ..... ................ [Infor] is dealing with: 3 [Infor] has been filtered sentence: system.out.println (value); [第 3 字] system [点号]. [Size] 14 [Identifier] OUT [Variety] 1 [Point Number]. [Size] 14 [Identifier] Println [ Not code] 1 [括] ([Variety] 8 [Identifier] Value [Size] 1 [Right Brand]) [Size] 9 ........... ...... End row 3 ....................................... ... Begin Row 4 .......................................................................... [4th line] [Right Big Brand]} [Various Code] 11 ................. End Row 4 ........... .............................. Begin Row 5 ............ ......... [infor] is dealing with: 5 [Infor] has been filtered sentence: public static void main (string [] args) { [5th line] [Reserved Word] PUBLIC [Reserved Word] Static [Reserved Word] Void [Identifier] Main [Size] 1 [Left Bracket] ([Size] 8 [Identifier] String [Symp Code] 1 [Left Brand] [[Variety] 12 [Right Brand]] [Variety] 13 [Identifier] Args [Size] 1 [Right Brand]) [Size] 9 [ Left big brackets] {[variety] 10 ................................................. ......................... Begin Row 6 .................. ... [Infor] is being processed: 6 [INFOR] Filtered sentence: aclass foo = new aclass (); [Chapter 6] [Identifier] ACLASS [Size] 1 [Identifier] Foo [Variety Code] 1 [ie] = [Value code] 3 [Reserved Word] New [Identifier] ACLASS [Variety] 1 [Left Bracket] ([Value Code] 8 [Right Brand]) [Size ] 9 ................. End Row 6 ........................ ................ Begin Row 7 ................................................................... : 7 [Infor] Filtered sentence: INT i = 0; [7th line] [Reserved Word] INT [INT] I [Various Code] 1 [Moral] = [Size] 3 [Number] 0 [Size] 2 ........ ........... End row 7 .................................. ........ begin row 8 .............................................................................................. .amethod (i); [8th line] [Identifier] FOO [Size] 1 [Click]. [Size] 14 [Identifier] AMETHOD [Size] 1 [Left Bracket] ([Size] 8 [ Identifier] I [Variety] 1 [Right Brand]) [Various Code] 9 ................. " ................................... Begin Row 9 .......... ............................................................................................................................................................... [9th line] [Identifier] i [variety code] 1 [equal sign] = [variety code] 3 [identifier] i [type code] 1 [plus] [variety code] 4 [ Number] 1 [Size] 2 ............................................. .......................... begin row 10 ...................... [Infor] is processing line: 10 [Infor] has been filtered sentence: foo.amethod (i); [10th line] [Identifier] FOO [Size] 1 [Point number]. [Size] 14 [Identifier] AMETHOD [Variety] 1 [Left Bracket] ([Size] 8 [ Identifier] I [Variety] 1 [Right Brand]) [Various Code] 9 ................. " ................................... Begin Row 11 .......... ...................................................................................................................................................... [11th line] [right braces]} [variety code] 11 ................. " ............................... Begin Row 12 ............ ......... [infor] is processing line: 12 [Infor] has been filtered sentence:}