資源簡介
任意給定一個上下文無關文法,通過程序計算文法所有非終結符FIRST和FOLLOW集,和每個產生式的SELECT集;
判斷該文法是否為LL(1)文法;
構造相應文法的預測分析表;
基于相應文法的預測分析表,動態演示(分步)一個句子分析過程。如果報錯,請提示可能的原因。參見教材P95表4.5;
設計、實現能根據分析結果(產生式序列)構建句子或者源程序的語法分析樹;
如果給定的文法含有左遞歸,嘗試對文法進行改寫,消除左遞歸;

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Collections;
namespace?LL1Paser
{
????public?class?Grammar
????{
????????//分析表
????????private?String[]?analyzeTable;
????????/**?
?????????*?LL(1)文法產生集合?
?????????*/
????????private?List?productionList;
????????/**?
?????????*?表達式集合?
?????????*/
????????private?Dictionary>?expressionMap;
????????/**?
?????????*?開始符?
?????????*/
????????private?char?s;
????????/**?
?????????*?Vn非終結符集合?
?????????*/
????????private?List?nvSet?=?new?List();
????????/**?
?????????*?Vt終結符集合?
?????????*/
????????private?List?ntSet?=?new?List();
????????/**?
?????????*?First集合?
?????????*/
????????private?Dictionary>?firstMap;
????????/**?
?????????*?Follow集合?
?????????*/
????????private?Dictionary>?followMap;
????????/**?
????????*?Select集合?
????????*/
????????Dictionary>>?selectMap;//
????????public?string[]?getAnalyzeTable()
????????{
????????????return?analyzeTable;
????????}
????????public?Dictionary>>?getSelectMap()
????????{
????????????return?selectMap;
????????}
????????public?void?setSelectMap(Dictionary>>?selectMap)
????????{
????????????this.selectMap?=?selectMap;
????????}
????????public?Dictionary>?getFirstMap()
????????{
????????????return?firstMap;
????????}
????????public?void?setFirstMap(Dictionary>?firstMap)
????????{
????????????this.firstMap?=?firstMap;
????????}
????????public?Dictionary>?getFollowMap()
????????{
????????????return?followMap;
????????}
????????public?void?setFollowMap(Dictionary>?followMap)
????????{
????????????this.followMap?=?followMap;
????????}
????????public?Dictionary>?getexpressionMap()
????????{
????????????return?expressionMap;
????????}
????????public?void?setexpressionMap(Dictionary>?expressionMap)
????????{
????????????this.expressionMap?=?expressionMap;
????????}
????????public?List?getGrammar()
????????{
????????????return?productionList;
????????}
????????public?void?setGrammar(List?productionList)
????????{
????????????this.productionList?=?productionList;
????????}
????????public?char?getS()
????????{
????????????return?s;
????????}
????????public?void?setS(char?s)
????????{
????????????this.s?=?s;
????????}
????????public?List?getNvSet()
????????{
????????????return?nvSet;
????????}
????????public?void?setNvSet(List?nvSet)
????????{
????????????this.nvSet?=?nvSet;
????????}
????????public?List?getNtSet()
????????{
????????????return?ntSet;
????????}
????????public?void?setNtSet(List?ntSet)
????????{
????????????this.ntSet?=?ntSet;
???
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v14\
?????文件???????54272??2017-12-20?17:18??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v14\.suo
?????目錄???????????0??2017-12-28?14:04??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\
?????文件???????71168??2017-12-28?14:04??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\.suo
?????文件?????4648960??2017-12-28?14:04??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\Browse.VC.db
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\Server\
?????目錄???????????0??2017-12-28?14:04??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\Server\sqlite3\
?????文件???????????0??2017-12-25?19:10??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\Server\sqlite3\db.lock
?????文件??????581632??2017-12-28?14:04??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\Server\sqlite3\storage.ide
?????目錄???????????0??2017-12-28?14:02??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\ipch\
?????目錄???????????0??2017-12-28?14:02??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\ipch\AutoPCH\
?????目錄???????????0??2017-12-28?14:02??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\ipch\AutoPCH\a493f13b77e1b77d\
?????文件????30539776??2017-12-28?14:02??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\.vs\LL1Paser\v15\ipch\AutoPCH\a493f13b77e1b77d\~VSE9AC.ipch
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\
?????文件???????19227??2017-12-20?09:58??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Grammar.cs
?????文件????????3816??2017-12-20?14:01??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\LL1Paser.csproj
?????文件???????16287??2017-12-27?16:20??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Main.Designer.cs
?????文件???????14226??2017-12-27?16:20??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Main.cs
?????文件????????5817??2017-12-27?16:20??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Main.resx
?????文件?????????488??2017-12-18?19:15??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Program.cs
?????目錄???????????0??2017-12-27?18:38??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Properties\
?????文件????????1366??2017-12-18?19:15??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Properties\AssemblyInfo.cs
?????文件????????2867??2017-12-18?19:15??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Properties\Resources.Designer.cs
?????文件????????5612??2017-12-18?19:15??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Properties\Resources.resx
?????文件????????1094??2017-12-18?19:15??03LL(1)分析程序\LL1\LL1Paser-Winform版\LL1Paser\LL1Paser\Properties\Settings.Designer.cs
............此處省略29個文件信息
評論
共有 條評論