1 19 20 package org.netbeans.editor; 21 22 import java.io.IOException ; 23 24 30 31 public class SyntaxDebug { 32 33 public static final String NO_STATE_ASSIGNED = "NO STATE ASSIGNED"; public static final String NULL_STATE = "NULL STATE"; public static final String NULL_SYNTAX_MARK = "NULL SYNTAX MARK"; 37 public Syntax syntax; 38 39 public SyntaxDebug(Syntax syntax) { 40 this.syntax = syntax; 41 } 42 43 46 public int parseFile(String fileName) 47 throws IOException { 48 char chars[] = Analyzer.loadFile(fileName); syntax.load(null, chars, 0, chars.length, true, 0); 50 int tokenCnt = debugScan(); 51 return tokenCnt; 52 } 53 54 57 public int debugScan() { 58 int tokenCnt = 0; 59 while (true) { 60 TokenID tokenID = syntax.nextToken(); 61 if (tokenID == null) { System.out.println("EOT at offset=" + syntax.getTokenOffset()); return tokenCnt; 64 } else { tokenCnt++; 66 System.out.println(tokenID.getName() + " in " + syntax.getTokenContextPath() + ": TEXT='" + EditorDebug.debugChars(syntax.getBuffer(), syntax.getTokenOffset(), syntax.getTokenLength()) 70 + "', offset=" + syntax.getTokenOffset() + ", len=" + syntax.getTokenLength() ); 73 } 74 } 75 } 76 77 80 101 106 111 167 197 198 } 199 | Popular Tags |