/// <summary> /// 为预测分析表设置表项 /// </summary> /// <param name="nEnum">产生式左侧非终结符号</param> /// <param name="tokenTypes">所有需要被设置表项的终结符号</param> /// <param name="treeNodes">构成产生式的语法分析树结点</param> public void SetParsingTable(NEnum nEnum, List <ParseTreeNode> treeNodes , params TerminalType[] tokenTypes) { ParsingTableItem tableItem; // 用于接收新建的预测分析表表项 foreach (TerminalType tEnum in tokenTypes) { // 将树结点添加到产生式中 tableItem = new ParsingTableItem(); tableItem.production.AddRange(treeNodes); this.GetItem(nEnum, tEnum).Add(tableItem); } }
/// <summary> /// 为预测分析表设置表项(产生式中由一个非终结符号构成) /// </summary> /// <param name="nEnum">产生式左侧非终结符号</param> /// <param name="production">构成产生式的非终结符号</param> /// <param name="tokenTypes">所有需要被设置表项的终结符号</param> public void SetParsingTable(NEnum nEnum, NEnum production, params TerminalType[] tokenTypes) { ParsingTableItem tableItem; // 用于接收新建的预测分析表表项 ParseTreeNode treeNode; // 用于接收新建的语法分析树结点 foreach (TerminalType tEnum in tokenTypes) { // 将树结点添加到产生式中 tableItem = new ParsingTableItem(); treeNode = new ParseTreeNode(false, TerminalType.DEFAULT, production); tableItem.production.Add(treeNode); this.GetItem(nEnum, tEnum).Add(tableItem); } }