当前位置:首页 > 编译原理实验1
} }else{ } return false; //判断一个字符是否是数字 public boolean isDigit(char ch) { } //读入一个文件,将其内容转换成一个字符串 public String getFile(String fileName){ } //处理字符串中的换行和空格 public String yuChuLi(String str){ String ts = \int i; char ch,nc; for(i=0;i File file = new File(fileName); String str = null; try { } return str; Reader reader = new FileReader(file); char c[] = new char[1024]; int len = reader.read(c); str = new String(c, 0, len); reader.close(); e.printStackTrace(); if(ch>='0'&&ch<='9'){ } return true; return false; }else{ } catch (Exception e) { } } } ts = ts+ch; if(nc==' '||nc=='\\t'||nc=='\\r'){ } ts = ts+ch; continue; ch=' '; ts = ts + ch; }else{ }else if(ch==' '||ch=='\\t'||ch=='\\r'){ }else{ ch = str.charAt(str.length()-1); if(ch!=' '&&ch!='\\r'&&ch!='\\t'&&ch!='\\n'){ } return ts; ts = ts + ch; //将一个长字符串按照分割规则,分割成一个个的短的字符串 public ArrayList }else{ list.add(new Word(row,s)); s = \continue; if(ch==' '){ }else{ }else if(isDigit(ch)||isLetter(ch)){ } } } } if(isTwoOperator(s,ch)){ } s = s + ch; if(s==\ } s = s + ch; }else if(s==\row ++; list.add(new Word(row, s)); s = \if(ch!='$'){ } s = s + ch; row ++; }else{ }else{ }else{ }else{ if(s!=\ } return list; list.add(new Word(row, s)); //判断一个字符串是否符合规范 public boolean isIdent(String str){ } public boolean isTwoOperator(String str, char ch) { 第7页 共14页 char ch; int i; for(i=0;i if(caozuofu.get(i).equals(str)){ } break; ArrayList
共分享92篇相关文档