Token Stream Question

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by Greg Shaffer - Boulder
Avatar
Hi,

I use a TokenStream in my PostParse function of my semantic parser. I'm doing a forward parse by calling TokenStream.Read().

In certain situations, I call TokenStream.PeekReverse() and TokenStream.ReadReverse(). I expect those two functions to return the previous token, but instead they return the current token.

What is interesting is that the TokenStream's position changes, but the token that is returned is not what I expect. In order to get the previous token via TokenStream, I need to call ReadReverse twice.

Is this how it is supposed to work, or is this a bug?

Thanks,
Greg

Comments (1)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
The code for that stream is pretty simple so there shouldn't be any bugs in it. The Position property of the TokenStream is essentially the "current" token index. If you do a Read or Peek, it returns the Token at that token index. If you do a ReadReverse or PeekReverse, it returns the Token before the current token index.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.