词法分析器(c#实现)

词法分析器(c#实现)

ID:10885449

大小:47.00 KB

页数:7页

时间:2018-07-08

词法分析器(c#实现)_第1页
词法分析器(c#实现)_第2页
词法分析器(c#实现)_第3页
词法分析器(c#实现)_第4页
词法分析器(c#实现)_第5页
资源描述:

《词法分析器(c#实现)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、/**********************************************************************************************************************写在最前面*词法分析前先将源码预处理,去掉多余的空格和换行以及注释*单词与单词之间最好用空格隔开,否则将被识别为未知符号******************************************************************************************************************

2、****/usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Collections;usingSystem.Text;usingSystem.Windows.Forms;usingSystem.IO;namespace词法分析{publicpartialclassForm1:Form{privatestaticstring[]保留字={"bool","break","case","char",

3、"do","double","else","false","float","for","if","int","long","main","new","null","private","protected","public","static","true","try","typeof","unit","void","while","return","short","sizeof","switch"};privatestaticstring[]运算符={"*","/","%","+","-","<<",">>","<",">","<=",">=","==","!=","&","^",

4、"

5、","&&","

6、

7、","?:","+=","-=","*=","/=","%=","&=","

8、=","^=","<<=",">>=","="};privatestaticstring[]界符={",",";",".","'","(",")",":","[","]","{","}","/"};privatestaticstring[]标识符;privatestaticstring[]常数;privatestaticstring[]未知符号;privateArrayListtemp=newArrayList();publicForm1(){InitializeComponen

9、t();}publicintSearch_Location(stringstr,string[]a)//查找字符编码{for(inti=0;i

10、++){temp.Add(a[j]);}temp.Add(strr);}a=(string[])temp.ToArray(typeof(string));returna.Length-1;}privatestringPretreatment()//预处理{strings1=textBox1.Text;stringstr1=null;//去除换行和//注释string[]str=textBox1.Lines;for(inti=0;i

11、r[i]=strr[0];}}for(inti=0;i

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。