資源描述:
《詞法分析器的源程序java》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在行業(yè)資料-天天文庫。
1、源程序packageAnalyer;importjava.io.File;importjava.io.FileReader;importjava.io.BufferedReader;importjava.io.FileNotFoundException;importjava.io.IOException;importjava.util.ArrayList;importjava.util.HashMap;publicclassanalyetest{publicArrayListbracket;publicArrayListkeyword;publicArray
2、Listsymbol;publicArrayListsemicolon;publicArrayListoperator;staticHashMapBRACKET;staticHashMapKEYWORD;staticHashMapSEMICOLON;staticHashMapOPERATOR;publicanalyetest(){this.KEYWORD=newHashMap();this.BRACKET=newHashMap();this.SEMICOLON=newHashMap();this.OPERATOR=newHashMap();this.brac
3、ket=newArrayList();this.keyword=newArrayList();this.symbol=newArrayList();this.semicolon=newArrayList();this.operator=newArrayList();}publicvoidinit(){initBracket();initKeyword();initSemicolon();initOperator();}publicvoidinitBracket(){this.BRACKET.put("(","(");this.BRACKET.put(")",
4、")");this.BRACKET.put("[","[");this.BRACKET.put("]","]");this.BRACKET.put("{","{");this.BRACKET.put("}","}");}publicvoidinitKeyword(){this.KEYWORD.put("class","class");this.KEYWORD.put("package","package");this.KEYWORD.put("this","this");this.KEYWORD.put("abstract","abstract");this
5、.KEYWORD.put("boolean","boolean");this.KEYWORD.put("break","break");this.KEYWORD.put("byte","byte");this.KEYWORD.put("case","case");this.KEYWORD.put("cast","cast");this.KEYWORD.put("catch","catch");this.KEYWORD.put("char","char");this.KEYWORD.put("continue","continue");this.KEYWORD
6、.put("default","default");this.KEYWORD.put("do","do");this.KEYWORD.put("double","double");this.KEYWORD.put("else","else");this.KEYWORD.put("extends","extends");this.KEYWORD.put("false","false");this.KEYWORD.put("final","final");this.KEYWORD.put("finally","finally");this.KEYWORD.put
7、("float","float");this.KEYWORD.put("for","for");this.KEYWORD.put("future","future");this.KEYWORD.put("generic","generic");this.KEYWORD.put("if","if");this.KEYWORD.put("implements","implements");this.KEYWORD.put("import","import");this.KEYWORD.put("inner","inner");this.KEYWORD.put("
8、instanceof","instanceof");