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

📄 frmoutput.frm

📁 本程序在JAVA编程环境实现了递归下降法的一个教学演示系统,可方便理解递归下降法的全过程!
💻 FRM
📖 第 1 页 / 共 2 页
字号:
      ForeColor       =   &H00FF0000&
      Height          =   315
      Left            =   7305
      TabIndex        =   7
      Top             =   120
      Width           =   990
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      BackColor       =   &H00FFFF80&
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   18
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000C0&
      Height          =   360
      Left            =   2880
      TabIndex        =   5
      Top             =   240
      Width           =   210
   End
   Begin VB.Label Label4 
      AutoSize        =   -1  'True
      BackColor       =   &H00C0C0FF&
      Caption         =   "代 码 生 成"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   315
      Left            =   240
      TabIndex        =   3
      Top             =   240
      Width           =   1935
   End
   Begin VB.Label Label3 
      AutoSize        =   -1  'True
      BackColor       =   &H00C0C0FF&
      Caption         =   "符  号  表"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   15.75
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FF0000&
      Height          =   315
      Left            =   3960
      TabIndex        =   2
      Top             =   960
      Width           =   1770
   End
End
Attribute VB_Name = "frmOutput"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Command1_Click()
Me.Hide
End Sub

Private Sub Form_Load()
With varTable
   .Row = 0
   .Col = 0
   .Text = "序号"
   .Col = 1
   .Text = "变量名"
   .Col = 2
   .Text = "类型"
   .Col = 3
   .Text = "地址"
End With

End Sub

Private Sub HScroll1_Change()
s = HScroll1.Value
End Sub

Private Sub run_Click()
    Dim Label(100) As Integer
    Dim i As Integer, inText As String
    Dim command(1) As String
    output.Clear
    stack.Clear
    For i = 0 To lstCode.ListCount - 1
        lstCode.ListIndex = i
        If Right$(lstCode.List(i), 1) = ":" Then
            Label(Val(Mid$(lstCode.List(i), 6, Len(lstCode.List(i)) - 6))) = i '用label数组记住每个标号的地址
        End If
    Next i
    For i = 0 To lstCode.ListCount - 1
        lstCode.ListIndex = i
        Sleep
        If Check1.Value = 1 Then MsgBox "继续"
        command(0) = Trim$(Left$(lstCode.List(i), 15))
        command(1) = Mid$(lstCode.List(i), 16)
        Select Case command(0)
        Case "LOAD"
            data.Row = Val(command(1))
            data.Col = 1
            stack.AddItem data.Text
            stack.ListIndex = stack.ListCount - 1
        Case "LOADI" 'LOADI a将常量a压入操作数栈
            stack.AddItem command(1)
            stack.ListIndex = stack.ListCount - 1
        Case "STO" 'STO D 将操作数栈栈顶单元内容存入D,且栈顶单元内容保持不变。
            data.Row = Val(command(1))
            data.Col = 1
            data.Text = stack.Text
        Case "STI" 'STI D 将操作数栈栈顶单元内容存入D,且栈顶单元内容出栈。
            data.Row = Val(command(1))
            data.Col = 1
            data.Text = stack.Text
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "ADD" 'ADD将次栈顶单元与栈顶单元内容出栈并相加,和置于栈顶。
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) + Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "SUB" 'SUB 将次栈顶单元减去栈顶单元内容并出栈,差置于栈顶。
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) - Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "MULT" 'MULT   将次栈顶单元与栈顶单元内容出栈并相乘,积置于栈顶。
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) * Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "DIV" 'DIV    将次栈顶单元与栈顶单元内容出栈并相除,商置于栈顶。
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) \ Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "BR" 'BR    lab  无条件转移到lab
            i = Label(Val(Mid$(command(1), 6, 10)))
            stack.ListIndex = stack.ListCount - 1
        Case "BRF" 'BRF  lab  检查栈顶单元逻辑值,若为假(0)则转移到lab
            If stack.Text = "False" Then i = Label(Val(Mid$(command(1), 6, 10)))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "EQ" 'EQ  将栈顶两单元做等于比较,并将结果真或假(1或0)置于栈顶
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) = Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "NOTEQ" 'NOTEQ 将栈顶两单元做不等于比较,并将结果真或假(1或0)置于栈顶
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) <> Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "GT" 'GT    次栈顶大于栈顶操作数,则栈顶置1,否则置0
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) > Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "LES" 'LES  次栈顶小于栈顶操作数,则栈顶置1,否则置0
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) < Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "GE" 'GE  次栈顶大于等于栈顶操作数,则栈顶置1,否则置0
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) >= Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "LE" 'LE  次栈顶小于等于栈顶操作数,则栈顶置1,否则置0
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) <= Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "AND" 'AND 将栈顶两单元做逻辑与运算,并将结果真或假(1或0)置于栈顶
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) And Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "OR" 'OR  将栈顶两单元做逻辑或运算,并将结果真或假(1或0)置于栈顶
            stack.List(stack.ListCount - 2) = Val(stack.List(stack.ListCount - 2)) Or Val(stack.List(stack.ListCount - 1))
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "NOT" 'NOT  将栈顶的逻辑值取反
            stack.List(stack.ListCount - 1) = Not stack.List(stack.ListCount - 1)
        Case "IN" 'IN 从标准输入设备(键盘)读入一个整型数据,并入栈。
            inText = InputBox("请输入整数数据:")
            stack.AddItem inText
            stack.ListIndex = stack.ListCount - 1
        Case "OUT" 'OUT 将栈顶单元内容出栈,并输出到标准输出设备上(显示器)。
            output.AddItem stack.Text
            stack.RemoveItem stack.ListCount - 1
            stack.ListIndex = stack.ListCount - 1
        Case "STOP" 'STOP 停止执行
            MsgBox "运行结束"
            Exit Sub
        End Select
    Next i
End Sub



Private Sub Timer1_Timer()
s = Val(HScroll1.Value) * 1000
End Sub

⌨️ 快捷键说明

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