自己写吧,我找到一点,参考参考Global Const MaxStack = 200 Global Const MaxVary = 200 Type StackForm DataStr(1 To MaxStack) As String TopPoint As Integer End TypeType VaryForm VaryArray(1 To MaxVary) As String ConstArray(1 To MaxVary) As String TopPoint As Integer End TypeGlobal DataStack As StackForm Global OpStack As StackForm Global VaryConst As VaryForm '****************************************** ' * ' 操作数出栈 * ' * '****************************************** Function PopData() As String PopData = DataStack.DataStr(DataStack.TopPoint) DataStack.TopPoint = DataStack.TopPoint - 1 End Function'****************************************** ' * ' 操作符出栈 * ' * '****************************************** Function PopOp() As String PopOp = OpStack.DataStr(OpStack.TopPoint) OpStack.TopPoint = OpStack.TopPoint - 1 End FunctionFunction PopVary() As String If VaryConst.TopPoint > 0 Then VaryConst.TopPoint = VaryConst.TopPoint - 1 OpVary = ".T." Else OpVary = ".F." End If End Function'****************************************** ' * ' 操作数压栈 * ' * '****************************************** Sub PushData(Element As String) PreWord = Element DataStack.TopPoint = DataStack.TopPoint + 1 DataStack.DataStr(DataStack.TopPoint) = Element End Sub'****************************************** ' * ' 操作符压栈 * ' * '****************************************** Sub PushOp(Element As String) PreWord = Element OpStack.TopPoint = OpStack.TopPoint + 1 OpStack.DataStr(OpStack.TopPoint) = Element End SubSub PushVary(VaryStr As String, ConstStr As String) VaryConst.TopPoint = VaryConst.TopPoint + 1 VaryConst.VaryArray(VaryConst.TopPoint) = VaryStr VaryConst.ConstArray(VaryConst.TopPoint) = ConstStr End Sub'****************************************** ' * ' 判断堆栈是否为空 * ' * '****************************************** Function StackEmpty(StackName As StackForm) As String If StackName.TopPoint = 0 Then StackEmpty = ".T." Else StackEmpty = ".F." End If End Function '****************************************** ' * ' 取操作符栈顶值但不弹出栈 * ' * '****************************************** Function TopValue() As String TopValue = OpStack.DataStr(OpStack.TopPoint) End Function
Global Const MaxVary = 200
Type StackForm
DataStr(1 To MaxStack) As String
TopPoint As Integer
End TypeType VaryForm
VaryArray(1 To MaxVary) As String
ConstArray(1 To MaxVary) As String
TopPoint As Integer
End TypeGlobal DataStack As StackForm
Global OpStack As StackForm
Global VaryConst As VaryForm
'******************************************
' *
' 操作数出栈 *
' *
'******************************************
Function PopData() As String
PopData = DataStack.DataStr(DataStack.TopPoint)
DataStack.TopPoint = DataStack.TopPoint - 1
End Function'******************************************
' *
' 操作符出栈 *
' *
'******************************************
Function PopOp() As String
PopOp = OpStack.DataStr(OpStack.TopPoint)
OpStack.TopPoint = OpStack.TopPoint - 1
End FunctionFunction PopVary() As String
If VaryConst.TopPoint > 0 Then
VaryConst.TopPoint = VaryConst.TopPoint - 1
OpVary = ".T."
Else
OpVary = ".F."
End If
End Function'******************************************
' *
' 操作数压栈 *
' *
'******************************************
Sub PushData(Element As String)
PreWord = Element
DataStack.TopPoint = DataStack.TopPoint + 1
DataStack.DataStr(DataStack.TopPoint) = Element
End Sub'******************************************
' *
' 操作符压栈 *
' *
'******************************************
Sub PushOp(Element As String)
PreWord = Element
OpStack.TopPoint = OpStack.TopPoint + 1
OpStack.DataStr(OpStack.TopPoint) = Element
End SubSub PushVary(VaryStr As String, ConstStr As String)
VaryConst.TopPoint = VaryConst.TopPoint + 1
VaryConst.VaryArray(VaryConst.TopPoint) = VaryStr
VaryConst.ConstArray(VaryConst.TopPoint) = ConstStr
End Sub'******************************************
' *
' 判断堆栈是否为空 *
' *
'******************************************
Function StackEmpty(StackName As StackForm) As String
If StackName.TopPoint = 0 Then
StackEmpty = ".T."
Else
StackEmpty = ".F."
End If
End Function
'******************************************
' *
' 取操作符栈顶值但不弹出栈 *
' *
'******************************************
Function TopValue() As String
TopValue = OpStack.DataStr(OpStack.TopPoint)
End Function