词法分析器

  • e0_451929
    了解作者
  • 120.5KB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-03 13:34
    上传日期
待分析的简单的词法 (1)注释: 以“//”开头到该行尾部为注释 (2)关键字(共6个): int real if then else while (3)标识符(ID)和整型常数(NUM): 以字母(ID)开头,后跟字母或数字的符号串,最长为64个字符。(注意:关键字不是标识符) ID = letter (letter | digit)* NUM=digit digit* (4)操作符(共11个): + - / * = == < <= > >= != (5)分隔符(共5个): ( ) { } ; (6)数字(用正规式描述): digit  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 整数  digit+ (最大整数为231 ) exponent  E ( + | - |  ) digit+ (最大指数为128) fraction  . digit+ 实数  digit+ exponent | digit+ fraction ( exponent |  ) (7)空格有空白、制表符和换行符组成。空格一般用来分隔ID、数字、运算符、操作 符和关键字,词法分析阶段通常被忽略。
词法分析器.rar
  • 词法分析器
  • ljx.cpp
    6.4KB
  • 词法分析器.doc
    355KB
内容介绍
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta name="generator" content="pdf2htmlEX"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css"> <link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css"> <link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/62782f14d7996104df5a7560/raw.css"> <script src="https://static.pudn.com/base/js/compatibility.min.js"></script> <script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script> <script> try{ pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({}); }catch(e){} </script> <title></title> </head> <body> <div id="sidebar" style="display: none"> <div id="outline"> </div> </div> <div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/62782f14d7996104df5a7560/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">&#35789;&#27861;&#20998;&#26512;&#22120;&#30340;&#35774;&#35745;</div><div class="t m0 x2 h4 y3 ff1 fs1 fc0 sc0 ls0 ws0">&#19968;&#12289;&#23454;&#39564;&#30446;&#30340;</div><div class="t m0 x3 h5 y4 ff1 fs2 fc0 sc1 ls0 ws0">&#35774;&#35745;&#12289;&#32534;&#21046;&#24182;&#35843;&#35797;&#19968;&#20010;&#35789;&#27861;&#20998;&#26512;&#31243;&#24207;&#65292;&#21152;&#28145;&#23545;&#35789;&#27861;&#20998;&#26512;&#21407;&#29702;&#30340;&#29702;&#35299;&#12290;</div><div class="t m0 x2 h4 y5 ff1 fs1 fc0 sc0 ls0 ws0">&#20108;&#12289;&#23454;&#39564;&#35201;&#27714;</div><div class="t m0 x2 h5 y6 ff2 fs2 fc0 sc1 ls0 ws0">2.1 <span class="ff1">&#24453;&#20998;&#26512;&#30340;&#31616;&#21333;&#30340;&#35789;&#27861;</span></div><div class="t m0 x4 h5 y7 ff1 fs2 fc0 sc1 ls0 ws0">&#65288;<span class="ff2">1</span>&#65289;&#27880;<span class="ff2"> </span>&#37322;&#65306;<span class="ff2"> </span>&#20197;&#8220;<span class="ff2">//<span class="ff3">&#8221;</span></span>&#24320;&#22836;&#21040;&#35813;&#34892;&#23614;&#37096;&#20026;&#27880;&#37322;</div><div class="t m0 x4 h5 y8 ff1 fs2 fc0 sc1 ls0 ws0">&#65288;<span class="ff2">2</span>&#65289;&#20851;&#38190;&#23383;&#65306;&#65288;&#20849;<span class="_ _0"> </span><span class="ff2">6<span class="_ _0"> </span></span>&#20010;&#65289;&#65306;<span class="ff2">int real if then else while<span class="ff4"> </span></span></div><div class="t m0 x4 h5 y9 ff1 fs2 fc0 sc1 ls0 ws0">&#65288;<span class="ff2">3</span>&#65289;&#26631;&#35782;&#31526;&#65306;<span class="ff2"> </span>&#20197;&#23383;&#27597;&#24320;&#22836;&#65292;&#21518;&#36319;&#23383;&#27597;&#25110;&#25968;&#23383;&#30340;&#31526;&#21495;&#20018;&#65292;&#26368;&#38271;&#20026;<span class="_ _0"> </span><span class="ff2">64<span class="_ _0"> </span></span>&#20010;&#23383;&#31526;&#12290;&#65288;&#27880;&#24847;&#65306;&#20851;</div><div class="t m0 x5 h5 ya ff1 fs2 fc0 sc1 ls0 ws0">&#38190;&#23383;&#19981;&#26159;&#26631;&#35782;&#31526;&#65289;<span class="ff2"> </span></div><div class="t m0 x4 h5 yb ff1 fs2 fc0 sc1 ls0 ws0">&#65288;<span class="ff2">4</span>&#65289;&#25805;&#20316;&#31526;&#65306;&#65288;&#20849;<span class="_ _0"> </span><span class="ff2">11<span class="_ _0"> </span></span>&#20010;&#65289;&#65306;<span class="ff2"> + - / * = == &lt; &lt;= &gt; &gt;= != </span></div><div class="t m0 x4 h5 yc ff1 fs2 fc0 sc1 ls0 ws0">&#65288;<span class="ff3">5</span>&#65289;&#20998;&#38548;&#31526;&#65306;&#65288;&#20849;<span class="_ _0"> </span><span class="ff2">5<span class="_ _0"> </span></span>&#20010;&#65289;&#65306;<span class="ff2"> ( ) { } ; </span></div><div class="t m0 x4 h5 yd ff1 fs2 fc0 sc1 ls0 ws0">&#65288;<span class="ff2">6</span>&#65289;&#25968;&#23383;&#65288;&#29992;&#27491;&#35268;&#24335;&#25551;&#36848;&#65289;&#65306;</div><div class="t m0 x6 h5 ye ff2 fs2 fc0 sc1 ls0 ws0">digit <span class="ff5">&#61612;</span> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 <span class="ff1">&#25972;&#25968;</span> <span class="ff5">&#61612;</span> digit</div><div class="t m0 x7 h6 yf ff2 fs3 fc0 sc1 ls0 ws0">+</div><div class="t m0 x8 h5 ye ff2 fs2 fc0 sc1 ls0 ws0"> (<span class="ff1">&#26368;&#22823;&#25972;&#25968;&#20026;<span class="_ _0"> </span></span>2</div><div class="t m0 x9 h6 yf ff2 fs3 fc0 sc1 ls0 ws0">31</div><div class="t m0 xa h7 ye ff2 fs2 fc0 sc1 ls0 ws0">)</div><div class="t m0 x6 h7 y10 ff2 fs2 fc0 sc1 ls0 ws0">exponent <span class="ff5">&#61612;</span> E ( + | - | <span class="ff5">&#61541;</span> ) digit</div><div class="t m0 xb h6 y11 ff2 fs3 fc0 sc1 ls0 ws0">+</div><div class="t m0 xc h5 y10 ff2 fs2 fc0 sc1 ls0 ws0"> (<span class="ff1">&#26368;&#22823;&#25351;&#25968;&#20026;<span class="_ _0"> </span></span>128)</div><div class="t m0 xd h7 y12 ff2 fs2 fc0 sc1 ls0 ws0">fraction <span class="ff5">&#61612;</span> . digit</div><div class="t m0 xe h6 y13 ff2 fs3 fc0 sc1 ls0 ws0">+</div><div class="t m0 xf h5 y12 ff2 fs2 fc0 sc1 ls0 ws0"> <span class="ff1">&#23454;&#25968;</span> <span class="ff5">&#61612;</span> digit</div><div class="t m0 x10 h6 y13 ff2 fs3 fc0 sc1 ls0 ws0">+</div><div class="t m0 x11 h7 y12 ff2 fs2 fc0 sc1 ls0 ws0"> exponent | digit</div><div class="t m0 x12 h6 y13 ff2 fs3 fc0 sc1 ls0 ws0">+</div><div class="t m0 x7 h7 y12 ff2 fs2 fc0 sc1 ls0 ws0"> fraction ( exponent | <span class="ff5">&#61541;</span> )</div><div class="t m0 x2 h5 y14 ff2 fs2 fc0 sc1 ls0 ws0">2.2 <span class="ff1">&#21508;&#31181;&#21333;&#35789;&#31526;&#21495;&#23545;&#24212;&#30340;&#31181;&#21035;&#30721;&#65306;</span></div><div class="t m0 x13 h8 y15 ff1 fs4 fc0 sc1 ls0 ws0">&#21333;&#35789;&#31526;&#21495;<span class="_ _1"> </span>&#31181;&#21035;&#30721;<span class="ff2"> syn<span class="_ _2"> </span></span>&#21333;&#35789;&#31526;&#21495;<span class="_ _3"> </span>&#31181;&#21035;&#30721;</div><div class="t m0 x14 h9 y16 ff2 fs4 fc0 sc1 ls0 ws0">int<span class="_ _4"> </span>1<span class="_ _4"> </span>=<span class="_ _5"> </span>14</div><div class="t m0 x6 h9 y17 ff6 fs5 fc0 sc1 ls0 ws0">real<span class="ff2 fs4"> </span></div><div class="t m0 x15 h9 y18 ff2 fs4 fc0 sc1 ls0 ws0">2<span class="_ _6"> </span>==<span class="_ _7"> </span>15</div><div class="t m0 x16 h9 y19 ff2 fs4 fc0 sc1 ls0 ws0">If <span class="_ _8"> </span>3<span class="_ _4"> </span>&lt;<span class="_ _5"> </span>16</div><div class="t m0 xd h9 y1a ff2 fs4 fc0 sc1 ls0 ws0">then <span class="_ _9"> </span>4<span class="_ _6"> </span>&lt;=<span class="_ _7"> </span>17</div><div class="t m0 x17 h9 y1b ff2 fs4 fc0 sc1 ls0 ws0">else <span class="_ _a"> </span>5<span class="_ _4"> </span>&gt;<span class="_ _5"> </span>18</div><div class="t m0 x6 h9 y1c ff2 fs4 fc0 sc1 ls0 ws0">while <span class="_ _b"> </span>6<span class="_ _6"> </span>&gt;=<span class="_ _7"> </span>19</div><div class="t m0 xd h9 y1d ff2 fs4 fc0 sc1 ls0 ws0">digit <span class="_ _c"> </span>7<span class="_ _d"> </span>{<span class="_ _e"> </span>20</div><div class="t m0 x18 h9 y1e ff2 fs4 fc0 sc1 ls0 ws0">fraction<span class="ff6 fs5"> <span class="_ _f"> </span></span>8<span class="_ _d"> </span>}<span class="_ _e"> </span>21</div><div class="t m0 x19 h9 y1f ff6 fs5 fc0 sc1 ls0 ws0">exponent<span class="ff2 fs4"> </span></div><div class="t m0 x15 h9 y20 ff2 fs4 fc0 sc1 ls0 ws0">9<span class="_ _e"> </span>(<span class="_ _10"> </span>22</div><div class="t m0 x1a h8 y21 ff2 fs4 fc0 sc1 ls0 ws0">lettet<span class="ff1">&#65288;</span>letter|digit<span class="ff1">&#65289;</span>*</div><div class="t m0 x1b h9 y22 ff2 fs4 fc0 sc1 ls0 ws0">10<span class="_ _11"> </span>)<span class="_ _10"> </span>23</div><div class="t m0 x1c h9 y23 ff2 fs4 fc0 sc1 ls0 ws0">-<span class="_ _e"> </span>11<span class="_ _12"> </span>;<span class="_ _13"> </span>24</div><div class="t m0 x1d h9 y24 ff2 fs4 fc0 sc1 ls0 ws0">*<span class="_ _d"> </span>12<span class="_ _11"> </span>!<span class="_ _10"> </span>25</div><div class="t m0 x1c h9 y25 ff2 fs4 fc0 sc1 ls0 ws0">/<span class="_ _14"> </span>13<span class="_ _15"> </span> !=<span class="_ _16"> </span>26</div><div class="t m0 x16 h9 y26 ff2 fs4 fc0 sc1 ls0 ws0">+<span class="_ _4"> </span>27<span class="_ _15"> </span> #<span class="_ _17"> </span>0</div><div class="t m0 x2 h5 y27 ff2 fs2 fc0 sc1 ls0 ws0">2.3 <span class="ff1">&#35789;&#27861;&#20998;&#26512;&#31243;&#24207;&#30340;&#21151;&#33021;&#65306;</span></div><div class="t m0 x1e h5 y28 ff1 fs2 fc0 sc1 ls0 ws0">&#36755;&#20837;&#65306;&#25152;&#32473;&#25991;&#27861;&#30340;&#28304;&#31243;&#24207;&#23383;&#31526;&#20018;&#12290;</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div> </body> </html>
评论
    相关推荐
    • Git
      Git命令 版本库又名仓库( repository )Git Bash 列出隐藏文件 ls -ah 显示文件内容 cat <yourfile> 仓库初始化 cd <your> git init 把文件添加到仓库 git add <yourfile> 把文件提交到仓库 git commit -m ...
    • GitExtensions
      GitExtensions,git,中文
    • helloGit
      helloGit
    • 学习Git
      学习Git Ravi常用命令 git log --oneline -n5 Gerrit Confluence页面 > git diff # Compare "working tree" against the last (HEAD) commit on this branch. > git diff --cached # Compare "staged files"/"index...
    • git测试
      git测试
    • Git
      #LearningGit我的实践Git的本地和远程命令
    • git软件 
      Git软件 Git-2.18.0-64-bit软件.exe
    • 挑战git
      Git挑战 有两个分支, add-echo和add-reverse 。 这项挑战的目标是使用git rebase将两个提交都提交给master。 完成后,应该没有合并提交或分支。 例如, master分支上的git log应该看起来像这样: /challenge-git ...
    • git学习
      Git入门学习 git的基本操作 创建仓库:git init 添加文件到仓库:git add README.md(提交附件文件)git add -A(提交所有文件)补充:(查看添加状态git status) 提交仓库:git commit -m'提交说明' 建立远程仓库...
    • 挑战git
      离群工程Git挑战 在Outlier,您将能够提供功能和修复程序而不会引起冲突和其他版本控制麻烦。 保持代码库干净的重要工具是git rebase 。 这项挑战将考验您对基本代码库的理解以及正确使用git rebase能力。 挑战 此...