Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: a parsing subtlety


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   st: a parsing subtlety
Date   Thu, 25 Aug 2005 06:19:00 -0500

One subtlety when parsing non-standard syntax is the following. Suppose you're parsing on ".", and you run into two or more of these characters together. In this case, -gettoken- does the following:


. loc foo "..."

. gettoken tok foo : foo, parse(".")

. di "|`tok'|"
|.|

. gettoken tok foo : foo, parse(".")

. di "|`tok'|"
|.|

. gettoken tok foo : foo, parse(".")

. di "|`tok'|"
|.|


By contrast, suppose you're parsing on "=":


. loc foo "==="

. gettoken tok foo : foo, parse("=")

. di "|`tok'|"
|==|

. gettoken tok foo : foo, parse("=")

. di "|`tok'|"
|=|


In other words, when parsing on "=" -gettoken- treats "==" as though it were "=". It's not hard to image how this behavior might be useful, given the special status of "==" as a relational operator. Still, unless I missed it, this special treatment of "=" is not mentioned in [P] gettoken. I haven't had a need to change this behavior, so I'm not asking for a "treat '=' as other characters" option on -gettoken-. But a sentence in the manual would save me from having to figure this out again each time I run across it ;)


-- Phil
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index