资源简介
C#2010完整开发编译原理(词法分析+LL(1)分析),词法分析实现输入代码自动标识关键字(该颜色,智能编程环境,不限语言),LL(1)分析实现输入文法,求解FIRST,FOLLOW集,得出预测分析表,匹配字符串。
代码片段和文件信息
using System;
using System.Text;
using System.Windows.Forms.Design;
using System.IO;
public class Arithmetic{
private string vnSign = null;
private string vtSign = null;
private StringBuilder strTransport = null;
private char nullSign = ‘\0‘;
const char dollarSign = ‘$‘;
const char pound = ‘#‘;
private string[] first1Collection = null;
private string[] first2Collection = null;
private string[] followCollection = null;
private string[] selectCollection = null;
private string[] tableOfNullSign = null;
private string[] anaylsisTable = null;
private Grammar grammar = null;
public string VnSign{
get{
return this.vnSign;
}
}
public string VtSign{
get{
return this.vtSign;
}
}
public char NullSign{
get{
return this.nullSign;
}
}
public string[] First1Collection{
get{
return this.first1Collection;
}
}
public string[] First2Collection{
get{
return this.first2Collection;
}
}
public string[] FollowCollection{
get{
return this.followCollection;
}
}
public string[] SelectCollection{
get{
return this.selectCollection;
}
}
public string[] TableOfNullSign{
get{
return tableOfNullSign;
}
}
public string[] AnaylsisTable
{
get{
return anaylsisTable;
}
}
public Grammar Grammar{
get{
return this.grammar;
}
}
public void SetGrammar(Grammar grammar){
this.grammar = grammar;
}
public void ComputeSignCollection(){
for (int i = 0; i < grammar.Amount; i++)
{
for (int j = 0; j < grammar[i].Length; j++)
{
if (System.Char.IsUpper(grammar[i][j]))
{
SetCollectionValue(ref vnSign grammar[i][j]);
}
else if (grammar[i][j] == dollarSign)
{
if (nullSign == ‘\0‘)
nullSign = grammar[i][j];
}
else
{
if (grammar[i][j] == dollarSign || grammar[i][j] == pound)
{
break;
}
else if (grammar[i][j] == ‘-‘ && grammar[i][j + 1] == ‘>‘)
{
j += 1;
continue;
}
else
{
SetCollectionValue(ref vtSign grammar[i][j]);
}
}
}
}
SortCollection(vnSign.Substring(1 vnSign.Length - 1));
vnSign = vnSign.Remove(1);
vnSign += strTransport.ToString();
SortCollection(vtSign);
vtSign = strTransport.ToString();
}
private void SortCollection(string str){
in
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2015-01-12 23:19 translation\
目录 0 2015-02-24 19:51 translation\translation\
文件 875 2015-01-12 23:19 translation\translation.sln
文件 23552 2015-02-27 14:20 translation\translation.suo
文件 30966 2015-02-24 22:22 translation\translation\Arithmetic.cs
目录 0 2015-02-15 11:22 translation\translation\bin\
目录 0 2015-02-27 11:31 translation\translation\bin\Debug\
文件 367 2015-02-28 11:46 translation\translation\bin\Debug\a.txt
文件 34816 2015-02-27 14:19 translation\translation\bin\Debug\translation.exe
文件 85504 2015-02-27 14:19 translation\translation\bin\Debug\translation.pdb
文件 11600 2015-02-27 14:20 translation\translation\bin\Debug\translation.vshost.exe
文件 490 2013-03-18 17:00 translation\translation\bin\Debug\translation.vshost.exe.manifest
目录 0 2015-02-15 11:22 translation\translation\bin\Release\
文件 155 2015-02-16 11:00 translation\translation\first.cs
文件 9686 2015-02-27 14:19 translation\translation\Form1.cs
文件 17302 2015-02-27 11:32 translation\translation\Form1.Designer.cs
文件 5817 2015-02-27 11:32 translation\translation\Form1.resx
文件 3893 2008-05-26 07:07 translation\translation\Grammar.cs
目录 0 2015-01-12 23:19 translation\translation\obj\
目录 0 2015-01-12 23:19 translation\translation\obj\x86\
目录 0 2015-02-27 14:19 translation\translation\obj\x86\Debug\
文件 5359 2015-01-14 14:51 translation\translation\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache
文件 6199 2015-02-27 14:19 translation\translation\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2015-01-12 23:19 translation\translation\obj\x86\Debug\TempPE\
文件 484 2015-02-27 14:20 translation\translation\obj\x86\Debug\translation.csproj.FileListAbsolute.txt
文件 975 2015-02-27 11:32 translation\translation\obj\x86\Debug\translation.csproj.GenerateResource.Cache
文件 34816 2015-02-27 14:19 translation\translation\obj\x86\Debug\translation.exe
文件 180 2015-02-27 11:32 translation\translation\obj\x86\Debug\translation.Form1.resources
文件 85504 2015-02-27 14:19 translation\translation\obj\x86\Debug\translation.pdb
文件 180 2015-02-27 11:31 translation\translation\obj\x86\Debug\translation.Properties.Resources.resources
文件 492 2015-01-12 23:19 translation\translation\Program.cs
............此处省略8个文件信息
评论
共有 条评论