package language; import java.util.Vector; public class LexicalAnalyzer extends java.lang.Object { public void setText(String text) { this.theText=text; } public void setBreakSymbols( char[] bsym) { this.breakSymbols=bsym; this.nOfBreakSym=bsym.length; } public LexicalAnalyzer() { init(); } public boolean isTag() { if(isTheEnd()) return false; if(isC('<')){ int c=lookup2(); if(('a'<=c && c<='z')|| ('A'<=c && c<='Z')|| c=='!' || c=='/') return true; } return false; } public char lookup2() { char x; x=theText.charAt(1); return x; } public int tokenIndex; public boolean isBreak(char c) { nOfBreakSym=breakSymbols.length; for(int i=0;i')){ dmy=rStringConst(); dmy=rNot('>'); } if(!rC('>')) return false; return true; } public boolean rAny1() { if(theText==null) return false; if(theText.equals("")) return false; aToken=aToken+theText.substring(0,1); theText=theText.substring(1); return true; } public boolean rNot(char x) { if(theText.equals("")) return false; if(theText==null) return false; if(isNot(x)){ aToken=aToken+theText.substring(0,1); theText=theText.substring(1); return true; } return false; } public boolean isNot(char x) { if(isC(x)) return false; else return true; } public boolean rC(char x) { if(isTheEnd()) return false; if(isC(x)) { aToken=aToken+x; theText=theText.substring(1); return true; } else return false; } public boolean isC(char x) { if(isTheEnd()) return false; if(theText.charAt(0)==x) return true; else return false; } public boolean rBreak() { if(isTheEnd()) return false; if(isBreak()){ rAny1(); return true; } return false; } public String nextToken() { String rtn=(String)(tokens.elementAt(tokenIndex)); tokenIndex++; return rtn; } public void backToken(){ tokenIndex--; } public String theText; public boolean hasMoreTokens() { if(tokens==null) return false; if(tokenIndex>tokens.size()-1) return false; return true; } public String aToken; public boolean rStringConst() { if(!rC('\"')) return false; if(theText.equals("")) return false; if(theText==null) return false; while(!isC('\"')){ if(isC('\\')){ if(!rAny1()) return false; if(!rAny1()) return false; } if(isC('\n')){ return false; } if(!rAny1()) return false; } if(!rC('\"')) return false; return true; } public boolean isBreak() { if(isTheEnd()) return false; int c=lookup1(); nOfBreakSym=breakSymbols.length; for(int i=0;i', '(', ')', '[', ']', '{', '}', ' ', ',', ':', ';', '.', '?', '/', '*', '+', '-', '=', '&', '%', '\'', '$', '#', '!', '#', '"', '~', '|', '^','@','\t','\n','\r'}; public void comment() { /* input text ... html format ex. ... "" ... "" */ } }