91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 246KB
    文件類型: .rar
    金幣: 2
    下載: 1 次
    發(fā)布日期: 2021-08-28
  • 語言: C/C++
  • 標(biāo)簽: C#??WinForm??

資源簡介

實(shí)現(xiàn)了一個可用的C++語法分析器,從文件讀取源代碼,從左到右掃描每行該語言源程序的符號,拼成單詞,換成統(tǒng)一的內(nèi)部表示(token)。識別標(biāo)識符、數(shù)字、特殊字符、關(guān)鍵字等類別,刪除注釋行和空白符,打印出每行包含的記號的二元形式到目標(biāo)文件中去

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.IO;
using?System.Windows.Forms;
using?System.Collections;

namespace?詞法分析
{
????class?analyseToken
????{
????????protected?string?sourceFileName;
????????protected?string?builtFileName;

????????//Stack?st?=?new?Stack();?????????//用于括號匹配的棧
????????char[]?prog?=?new?char?[1000];??//暫存輸入字符
????????char[]?token?=?new?char[20];

????????char?ch;
????????int?p?=?0;
????????int?sym?=?0;
????????int?n;
????????int?errorLine;????//發(fā)生錯誤的行號
????????string[]?keyword?=?{?“if“?“else“?“while“?“for“?“do“?“return“
?????????“int“?“main““void““double““float““case““for““do““short““static“
????????“true““false““try““delete““class““break““bool““goto““default““using“
????????“new““continue““switch““throw““unsigned““signed““sizeof“};??//關(guān)鍵詞數(shù)組

????????public?analyseToken()?????//構(gòu)造函數(shù)
????????{
????????????Array.Clear(prog(char)01000);
????????}
????????public?void?setSourceFileName(string?file)
????????{
????????????sourceFileName?=?file;
????????}
????????public?void?setBuiltFileName(string?file)
????????{
????????????builtFileName?=?file;
????????}
????????protected?void?GetToken()
????????{
????????????ch?=?prog[p++];
????????????while?(ch?==?‘?‘?||?ch?==?‘\n‘?||?ch?==?‘\t‘?||(int)ch?==?13||(int)ch==9)?{?ch?=?prog[p++];?}

????????????for?(n?=?0;?n?????????????{
????????????????token[n]?=?‘\0‘;
????????????}
????????????n?=?0;

????????????if?((int)ch?==?0)
????????????{

????????????????return;
????????????}
????????????if?((ch?>=?‘a(chǎn)‘?&&?ch?<=?‘z‘)?||?(ch?>=?‘A‘?&&?ch?<=?‘Z‘)||ch?==?‘_‘)
????????????{
????????????????sym?=?1;
????????????????do
????????????????{
????????????????????token[n++]?=?ch;
????????????????????ch?=?prog[p++];
????????????????}?while?((ch?>=?‘a(chǎn)‘?&&?ch?<=?‘z‘)?||?(ch?>=?‘A‘?&&?ch?<=?‘Z‘)||?(ch?>=?‘0‘?&&?ch?<=?‘9‘)||ch?==?‘_‘);
????????????????sym?=?2;

????????????????string?str1?=?null;

????????????????for?(int?i?=?0;?token[i]?!=?‘\0‘;?i++)
????????????????{

????????????????????str1?+=?token[i];
????????????????}
????????????????for?(n?=?0;?n<33;n++)
????????????????{
????????????????????if?(String.Compare(str1?keyword[n])?==?0)?????????????????????//關(guān)鍵詞匹配
????????????????????{
????????????????????????sym?=?n?+?23;
????????????????????}
????????????????}

????????????????p--;
????????????????
????????????}
????????????//else?if?(ch?==?‘{‘||ch?==?‘}‘?||?ch?==?‘(‘?||?ch?==?‘)‘?||?ch?==?‘[‘?||?ch?==?‘]‘)?????????????????????????????//括號處理
????????????//{
????????????//????if?(ch?==?‘{‘)
????????????//????{
????????????//????????sym?=?3;
????????????//????????//st.Push(ch);
????????????//????????token[0]?=?ch;
????????????//????}
????????????//????else?if?(ch?==?‘}‘)
????????????//????{
????????????//????????//if?((char)st.Peek()?==?‘{‘)
????????????//????????//{
????????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件?????????34??2018-09-27?20:32??詞法分析\.git\COMMIT_EDITMSG

?????文件????????966??2018-09-27?20:47??詞法分析\.git\config

?????文件?????????73??2018-09-26?20:23??詞法分析\.git\description

?????文件?????????95??2018-10-27?21:29??詞法分析\.git\FETCH_HEAD

?????文件?????????23??2018-09-26?20:23??詞法分析\.git\HEAD

?????文件????????478??2018-09-26?20:23??詞法分析\.git\hooks\applypatch-msg.sample

?????文件????????896??2018-09-26?20:23??詞法分析\.git\hooks\commit-msg.sample

?????文件????????189??2018-09-26?20:23??詞法分析\.git\hooks\post-update.sample

?????文件????????424??2018-09-26?20:23??詞法分析\.git\hooks\pre-applypatch.sample

?????文件???????1642??2018-09-26?20:23??詞法分析\.git\hooks\pre-commit.sample

?????文件???????1348??2018-09-26?20:23??詞法分析\.git\hooks\pre-push.sample

?????文件???????4951??2018-09-26?20:23??詞法分析\.git\hooks\pre-rebase.sample

?????文件????????544??2018-09-26?20:23??詞法分析\.git\hooks\pre-receive.sample

?????文件???????1239??2018-09-26?20:23??詞法分析\.git\hooks\prepare-commit-msg.sample

?????文件???????3610??2018-09-26?20:23??詞法分析\.git\hooks\update.sample

?????文件???????1651??2018-09-27?20:32??詞法分析\.git\index

?????文件????????240??2018-09-26?20:23??詞法分析\.git\info\exclude

?????文件????????705??2018-09-27?20:32??詞法分析\.git\logs\HEAD

?????文件????????705??2018-09-27?20:32??詞法分析\.git\logs\refs\heads\master

?????文件????????291??2018-09-27?20:48??詞法分析\.git\logs\refs\remotes\origin\master

?????文件????????151??2018-09-27?20:49??詞法分析\.git\ms-persist.xml

?????文件????????159??2018-09-27?20:32??詞法分析\.git\objects\01\8ccab423b8ff2be0b0b1d5ebbe706838b33297

?????文件????????211??2018-09-27?20:32??詞法分析\.git\objects\03\ee951297d3638b8313e506573b3d77948ab2fe

?????文件????????336??2018-09-26?20:23??詞法分析\.git\objects\12\3e53beac97ad68d8cabf508d5e056b5bc7f7d1

?????文件???????1191??2018-09-27?15:57??詞法分析\.git\objects\16\60a9e89ee45924fec52be0e35c56adf2cb3b5f

?????文件???????1665??2018-09-26?20:23??詞法分析\.git\objects\1a\f7de150c99c12dd67a509fe57c10d63e4eeb04

?????文件????????751??2018-09-26?20:23??詞法分析\.git\objects\1f\f0c423042b46cb1d617b81efb715defbe8054d

?????文件???????2497??2018-09-26?20:23??詞法分析\.git\objects\2c\f92f54932c34790d01ae5f248e0c82d5005e3c

?????文件???????2697??2018-09-27?20:32??詞法分析\.git\objects\35\c20ab01b8ea5b8baad2798cd47d0087b438cce

?????文件????????186??2018-09-26?20:23??詞法分析\.git\objects\39\645652af62950ebf3b28ec3a5400dcec30b1c4

............此處省略158個文件信息

評論

共有 條評論