资源简介

任意给定一个上下文无关文法,通过程序计算文法所有非终结符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个文件信息

评论

共有 条评论