help mata tokenpreview()

Title

tokenpreview() -- Peek ahead at tokens

Syntax

string rowvector
tokenpreview(t)

string rowvector
tokenpreview(t, real rowvector v)

where

t is a parsing environment obtained from
tokeninit() or
tokeninitstata().

v selects from t the tokens to be previewed.

Description

tokenpreview() is similar to tokenpeek()
and returns tokens from t without actually getting them.

If v is scalar, returned is

v>0 the vth token

v<0 the vth last token

v=0 "" (i.e., empty string)

v>=. all tokens (same as not specifying v)

If v is 1 x c, it may not contain missing. Returned
is 1 x c with elements according to the rules above.

Conformability

tokenpreview(t)
t: transmorphic
result: 1 x c

tokenpreview(t, v)
t: transmorphic
v: 1 x c
result: 1 x c

Diagnostics

tokenpreview() returns "" (i.e., empty string) for each v
if |v|>cols(tokengetall(t)). The function aborts
with error if v is 1 x c and contains missing.

Source code

Distributed with the elabel package.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: mata, tokenget()