⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 keyanalyse.java

📁 词法分析器 可以识别c++的源码,自动生成词法分析表, 在分析结束后会指出源代码中可能的错误 待分析的源代码要以 *源代码.txt的格式保存
💻 JAVA
字号:
package accidenceAnalyse;

import java.util.ArrayList;

public class KeyAnalyse //extends IdentifierAnalyse
{
	/*   关键字的词法分析*/
	public boolean keyAnalyse(String str ,ArrayList<TokenTable> list , ArrayList<String> errorList , int textLine){
		for(String ss : keyStr){
			if (ss.equals(str)){
				this.name = str;
				this.ID = 1;
				list.add(new TokenTable(this.ID,this.name));
				return true;
			}
		}
		return false;
	}
	// c++的关键字:
	final static String[] keyStr = { "and" , "and_eq" , "asm" , "auto" , "bitand" , "bitor",
													"bool" , "break" , "case" , "catch" , "char" , "class",
													"compl" , "const" , "const_cast" , "continue" , "defalt" , "delete",
													"do" , "doule" , "dynamic_cast" , "else" , "enum" , "explicit",
													"export" , "extern" , "false" , "float" , "for" , "friend",
													"goto" , "if" , "inline" , "int" , "long" , "mutable",
													"namespace" , "new" , "not" , "not_eq" , "operator" , "or",
													"or_eq" , "privat" , "protected" , "public" , "register" , "reinterpret_cast",
													"return" , "short" , "signed" , "sizeof" , "static" , "static_cast",
													"struct" , "switch" , "template" , "this" , "throw" , "ture",
													"try" , "typedef" , "typeid" , "typename" , "union" , "unsigned",
													"using" , "virtual" , "void" , "volatile" , "wchar_t" , "while",
													"xor" , "xor_eq"};
	private int ID = 0;
	private String name = ""; 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -