|
'----------------------------------------------------------------------
' Gold Parser engine.
' See more details on http:'www.devincook.com/goldparser/
'
' Original code is written in VB by Devin Cook (GOLDParser@DevinCook.com)
'
' This translation is done by Vladimir Morozov (vmoroz@hotmail.com)
'
' The translation is based on the other engine translations:
' Delphi engine by Alexandre Rai (riccio@gmx.at)
' C# engine by Marcus Klimstra (klimstra@home.nl)
'----------------------------------------------------------------------
Imports System
Imports System.Collections
Namespace GoldParser
''' <summary>
''' Stack of tokens.
''' </summary>
Class TokenStack
Inherits Stack
''' <summary>
''' Creates a new instance of the <c>TokenStack</c> class.
''' </summary>
Public Sub New()
MyBase.New()
End Sub
''' <summary>
''' Pushes token to the stack.
''' </summary>
''' <param name="token">Token to push to the stack.</param>
Public Sub PushToken(ByVal token As Token)
Push(token)
End Sub
''' <summary>
''' Pops token from the stack.
''' </summary>
''' <returns>Token from the stack.</returns>
Public Function PopToken() As Token
Return CType(Pop(), Token)
End Function
''' <summary>
''' Gets token from the top of the stack.
''' </summary>
''' <returns>Token from the top of the stack.</returns>
Public Function PeekToken() As Token
Return CType(Peek(), Token)
End Function
''' <summary>
''' Copies the token stack contents to the token array.
''' </summary>
''' <param name="array">Array to copy data to.</param>
''' <param name="index">Start index in the array to copy tokens.</param>
Public Shadows Sub CopyTo(ByVal array() As Token, ByVal index As Integer)
For Each token As Token In Me
array(index) = token
index += 1
Next
End Sub
End Class
End Namespace
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Adrian Moore is the Development Manager for the SCADA Vision system developed by ABB Inc in Calgary, Alberta.
He has been interested in compilers, parsers, real-time database systems and peer-to-peer solutions since the early 90's. In his spare time, he is currently working on a SQL parser for querying .NET DataSets (http://www.queryadataset.com).
Adrian is a Microsoft MVP for Windows Networking.