⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 编译原理的算符优先文法[网页版]).htm

📁 编译原理的算符优先文法[网页版]).htm 源程序对该算法的实现
💻 HTM
📖 第 1 页 / 共 2 页
字号:
      Mid(strArray(i), j, 1)) - 1) & a(Instr(tempStra, Mid(strArray(i), j + 
      1, 1)) - 1) &amp; =<BR>&nbsp;&nbsp; 'Response.write a(Instr(tempStra, 
      Mid(strArray(i), j, 1)) - 1) &amp; = &amp; a(Instr(tempStra, 
      Mid(strArray(i), j + 1, 1)) - 1) &amp; &lt;br&gt;<BR>&nbsp;End 
      If<BR>&nbsp;If j &lt;= Len(strArray(i)) - 2 And Instr(tempStra, 
      Mid(strArray(i), j, 1)) &gt; 0 And Instr(tempStra, Mid(strArray(i), j + 2, 
      1)) &gt; 0 And Instr(tempStrP, Mid(strArray(i), j + 1, 1)) &gt; 0 
      Then<BR>&nbsp;&nbsp; tabStr = tabStr &amp; a(Instr(tempStra, 
      Mid(strArray(i), j, 1)) - 1) &amp; a(Instr(tempStra, Mid(strArray(i), j + 
      2, 1)) - 1) &amp; =<BR>&nbsp;&nbsp; 'Response.write a(Instr(tempStra, 
      Mid(strArray(i), j, 1)) - 1) &amp; = &amp; a(Instr(tempStra, 
      Mid(strArray(i), j + 2, 1)) - 1) &amp; &lt;br&gt;<BR>&nbsp;End 
      If<BR>&nbsp;'------******------******------******------******------******------******------******------******------******<BR>&nbsp;If 
      Instr(tempStra, Mid(strArray(i), j, 1)) &gt; 0 And Instr(tempStrP, 
      Mid(strArray(i), j + 1, 1)) &gt; 0 Then<BR>&nbsp;&nbsp; For k = 1 to 
      Len(strFirstvt(Instr(tempStrP, Left(strArray(i), 
      1))))<BR>&nbsp;&nbsp;&nbsp;&nbsp; tabStr = tabStr &amp; a(Instr(tempStra, 
      Mid(strArray(i), j, 1)) - 1) &amp; Mid(strFirstvt(Instr(tempStrP, 
      Left(strArray(i), 1))), k, 1) &amp; &lt;<BR>&nbsp;&nbsp;'Response.write 
      a(Instr(tempStra, Mid(strArray(i), j, 1)) - 1) &amp; &amp;lt; &amp; 
      Mid(strFirstvt(Instr(tempStrP, Left(strArray(i), 1))), k, 1) &amp; 
      strArray(i) &amp; &lt;br&gt;<BR>&nbsp;&nbsp; Next<BR>&nbsp;End 
      If<BR>&nbsp;If Instr(tempStrP, Mid(strArray(i), j, 1)) &gt; 0 And 
      Instr(tempStra, Mid(strArray(i), j + 1, 1)) &gt; 0 Then<BR>&nbsp;&nbsp; 
      For k = 1 to Len(strLastvt(Instr(tempStrP, Left(strArray(i), 
      1))))&nbsp;'此处放LastVt集合<BR>&nbsp;&nbsp;tabStr = tabStr &amp; 
      Mid(strLastvt(Instr(tempStrP, Left(strArray(i), 1))), k, 1) &amp; 
      a(Instr(tempStra, Mid(strArray(i), j + 1, 1)) - 1) &amp; 
      &gt;<BR>&nbsp;&nbsp;'Response.write Mid(strLastvt(Instr(tempStrP, 
      Left(strArray(i), 1))), k, 1) &amp; &amp;gt; &amp; a(Instr(tempStra, 
      Mid(strArray(i), j + 1, 1)) - 1) &amp; &lt;br&gt;<BR>&nbsp;&nbsp; 
      Next<BR>&nbsp;End 
      If<BR>&nbsp;'------******------******------******------******------******------******------******------******------******<BR>&nbsp; 
      Next<BR>Next<BR>'Response.write Server.HTMLEncode(tabStr) &amp; &lt;br&gt; 
      &amp; 
      Len(tabStr)/3<BR>'--------------------------此处生成优先关系表格<BR>Response.write(&lt;li&gt;生成优先关系表如下: 
      &lt;/li&gt; &amp; vbcrlf)<BR>Response.write(&lt;table border=1&gt; &amp; 
      vbcrlf)<BR>Response.Write(&lt;tr align=center&gt; &amp; 
      vbcrlf)<BR>Response.Write(&lt;td width=30&gt;&amp;nbsp;&lt;/td&gt;)<BR>Dim 
      sub_a<BR>For each sub_a in a<BR>&nbsp; Response.Write(&lt;td width=30&gt; 
      &amp; sub_a &amp; &lt;/td&gt;)<BR>Next<BR>Response.Write(&lt;/tr&gt; &amp; 
      vbcrlf)<BR>For i = 0 to Ubound(a)<BR>&nbsp; Response.Write(&lt;tr 
      align=center&gt;&lt;td&gt; &amp; a(i) &amp; &lt;/td&gt;)<BR>&nbsp;For each 
      sub_a in a&nbsp;&nbsp;'此处生成对应的a,a的关系<BR>&nbsp;&nbsp; If Instr(tabStr, a(i) 
      &amp; sub_a) Then<BR>&nbsp;&nbsp;&nbsp;&nbsp; Response.write(&lt;td&gt; 
      &amp; Mid(tabStr, Instr(tabStr, a(i) &amp; sub_a) + 2, 1) &amp; 
      &lt;/td&gt;)<BR>&nbsp;&nbsp; Else<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
      Response.write(&lt;td&gt;&amp;nbsp;&lt;/td&gt;)<BR>&nbsp;&nbsp; End 
      If<BR>&nbsp;Next<BR>&nbsp; Response.write(&lt;/tr&gt; &amp; 
      vbcrlf)<BR>Next<BR>Response.write(&lt;/table&gt;&lt;br&gt;)<BR>'*******************************函数区域*******************************************************<BR>Function 
      outForL()&nbsp;&nbsp;&nbsp;'输出F(m, n)的值<BR>Response.Write(&lt;table 
      border=1&gt; &amp; vbcrlf)<BR>Response.Write(&lt;tr align=center&gt; &amp; 
      vbcrlf)<BR>Response.Write(&lt;td width=20&gt;&amp;nbsp;&lt;/td&gt;)<BR>For 
      j = 0 to n<BR>&nbsp; Response.Write(&lt;td width=20&gt; &amp; a(j) &amp; 
      &lt;/td&gt;)<BR>Next<BR>Response.Write(&lt;/tr&gt; &amp; vbcrlf)<BR>For i 
      = 0 to m<BR>&nbsp; Response.write(&lt;tr align=center&gt; &amp; 
      vbcrlf)<BR>&nbsp; Response.write(&lt;td&gt; &amp; P(i) &amp; 
      &lt;/td&gt;)<BR>&nbsp; For j = 0 to n<BR>&nbsp;&nbsp; 
      Response.write(&lt;td&gt; &amp; F(i, j) &amp; &lt;/td&gt;)<BR>&nbsp; 
      Next<BR>&nbsp; Response.write(&lt;/tr&gt; &amp; vbcrlf)<BR>Next<BR>&nbsp; 
      Response.write(&lt;/table&gt;&lt;br&gt;)<BR>End Function</P>
      <P>Function checkInput()&nbsp;'检查输入文法正确性<BR>&nbsp; For i = 0 to 
      Ubound(strArray)<BR>&nbsp;&nbsp;&nbsp; If Instr(strArray(i), -&gt;) 
      &lt;&gt; 2 or Len(strArray(i)) &lt; 4 Then<BR>&nbsp;&nbsp; checkInput = 
      false<BR>&nbsp;&nbsp; Exit Function<BR>&nbsp;End IF<BR>&nbsp; 
      Next<BR>&nbsp; checkInput = true<BR>End Function</P>
      <P>Function pToa(subP, suba)&nbsp;'检查是否P-&gt;a<BR>&nbsp; Dim 
      pToai<BR>&nbsp; For pToai = 0 to Ubound(strArray)<BR>&nbsp;&nbsp;&nbsp; If 
      Left(strArray(pToai), 1) = subp and Mid(strArray(pToai), 4, 1) = suba 
      Then<BR>&nbsp;&nbsp; ptoa = true<BR>&nbsp;&nbsp; Exit 
      Function<BR>&nbsp;End If<BR>&nbsp; Next<BR>&nbsp; pToa = false<BR>End 
      Function</P>
      <P>Function pTo_a(subP, suba)&nbsp;'检查是否P-&gt;a<BR>&nbsp; Dim 
      pTo_ai<BR>&nbsp; For pTo_ai = 0 to Ubound(strArray)<BR>&nbsp;&nbsp;&nbsp; 
      If Left(strArray(pTo_ai), 1) = subp and Mid(strArray(pTo_ai), 
      Len(strArray(pTo_ai)), 1) = suba Then<BR>&nbsp;&nbsp; pto_a = 
      true<BR>&nbsp;&nbsp; Exit Function<BR>&nbsp;End If<BR>&nbsp; 
      Next<BR>&nbsp; pTo_a = false<BR>End Function</P>
      <P>Function pToQa(subP, suba)&nbsp;'检查是否P-&gt;Qa<BR>&nbsp; Dim 
      pToQai<BR>&nbsp; For pToQai = 0 to Ubound(strArray)<BR>&nbsp;&nbsp;&nbsp; 
      If Left(strArray(pToQai), 1) = subp and Mid(strArray(pToQai), 5, 1) = suba 
      and Instr(tempStrP, Mid(strArray(pToQai), 4, 1)) Then<BR>&nbsp;&nbsp; 
      pToQa = true<BR>&nbsp;&nbsp; Exit Function<BR>&nbsp;End If<BR>&nbsp; 
      Next<BR>&nbsp; pToQa = false<BR>End Function</P>
      <P>Function pToaQ(subp, suba)<BR>&nbsp; Dim pToaQi<BR>&nbsp; For pToaQi = 
      0 to Ubound(strArray)<BR>&nbsp;&nbsp;&nbsp; If Left(strArray(pToaQi), 1) = 
      subp and Mid(strArray(pToaQi), Len(strArray(pToaQi)) - 1, 1) = suba and 
      Instr(tempStrP, Mid(strArray(pToaQi), Len(strArray(pToaQi)), 1)) 
      Then<BR>&nbsp;&nbsp; pToaQ = true<BR>&nbsp;&nbsp; Exit 
      Function<BR>&nbsp;End If<BR>&nbsp; Next<BR>&nbsp; pToaQ = false<BR>End 
      Function</P>
      <P>Function pushStack(s_P, s_a)&nbsp;&nbsp;'入栈stack<BR>&nbsp; Dim 
      boundStackPush<BR>&nbsp; If Ubound(stack, 2) Then<BR>&nbsp;boundStackPush 
      = Ubound(stack, 2)<BR>&nbsp; Else<BR>&nbsp;&nbsp;&nbsp; boundStackPush = 
      0<BR>&nbsp; End If<BR>&nbsp; ReDim Preserve stack(1, 
      boundStackPush+1)<BR>&nbsp; stack(0, boundStackPush+1) = s_P<BR>&nbsp; 
      stack(1, boundStackPush+1) = s_a<BR>End Function</P>
      <P>Function popStack()&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'出栈stack<BR>&nbsp; Dim 
      stackP, boundStackPop, r_p, r_a<BR>&nbsp; boundStackPop = Ubound(stack, 
      2)<BR>&nbsp; r_P = stack(0, boundStackPop)<BR>&nbsp; r_a = stack(1, 
      boundStackPop)<BR>&nbsp; ReDim Preserve stack(1, 
      boundStackPop-1)<BR>&nbsp; popStack = r_P &amp; &amp; r_a<BR>End 
      Function</P>
      <P>Function chStr()<BR>&nbsp; Dim tempStr<BR>&nbsp; For i = 0 to 
      Ubound(strArray)<BR>&nbsp;&nbsp;&nbsp; If Instr(strArray(i), |) 
      Then<BR>&nbsp;&nbsp; tempStr = Left(strArray(i), 3) &amp; 
      Right(strArray(i), Len(strArray(i)) - Instr(strArray(i), 
      |))<BR>&nbsp;&nbsp; strArray(i) = Left(strArray(i), Instr(strArray(i), |) 
      - 1)<BR>&nbsp;&nbsp; Redim Preserve strArray(Ubound(strArray) + 
      1)<BR>&nbsp;&nbsp; strArray(Ubound(strArray)) = tempStr<BR>&nbsp;&nbsp; 
      Call chStr<BR>&nbsp;End If<BR>&nbsp; Next<BR>End 
      Function<BR>'*********************************************************************************************<BR>If 
      err then<BR>Response.write(err.description)<BR>err.clear<BR>end 
      if<BR>Response.write(&lt;li&gt;&lt;a 
      href=a.htm&gt;返回&lt;/a&gt;&lt;/li&gt;&lt;br&gt;)<BR>%&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;</P>
      <P><FONT color=#ff0000><STRONG>a.htm</STRONG></FONT></P>
      <P><FONT 
      color=#000000>&lt;html&gt;<BR>&lt;title&gt;算符优先关系表生成程序&lt;/title&gt;<BR>&lt;style&gt;<BR>body&nbsp;{ 
      font-size: 14px }<BR>input&nbsp;{ font-size: 14px; height: 20px; border: 
      1px, solid; border-color: #666666; background: #ffffff 
      }<BR>&lt;/style&gt;<BR>&lt;body&gt;<BR>&lt;div&gt;<BR>&lt;br&gt;<BR>&lt;form 
      method=post 
      action=c.asp&gt;<BR>&lt;li&gt;请在下面文本框中输入文法(各式间以空格隔开,如:&lt;b&gt;&lt;font 
      color=blue&gt;E-&gt;E+T|T T-&gt;T*F|F F-&gt;P↑F|P 
      P-&gt;i|(E)&lt;/font&gt;&lt;/b&gt;)<BR>&lt;li&gt;&lt;input type=text 
      name=str size=100 value=E-&gt;E+T|T T-&gt;T*F|F F-&gt;P↑F|P 
      P-&gt;i|(E)&gt;<BR>&lt;li&gt;&lt;input type=Submit value=提交 
      onmouseover=this.style.background='yellow'; 
      onmouseout=this.style.background='white';&gt;<BR>&lt;input type=Reset 
      value=重置 onmouseover=this.style.background='yellow'; 
      onmouseout=this.style.background='white';&gt;<BR>&lt;/form&gt;<BR>&lt;/div&gt;<BR>&lt;/body&gt;<BR>&lt;/html&gt;</FONT></P></TD></TR></TBODY></TABLE></BODY></HTML>


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -