getParseData
Get Detailed Parse Information from Object
Description
Given a parsed expression, produce a data.frame containing detailed
information about the parsed expression, including comments.
Usage
getParseData(x, includeText = NA)
getParseText(parseData, id)
Arguments
  
| x | A parsed expression, as returned by parse.  The parsing
must be done with the keep.source argument equal to TRUE,
to keep the parsing information used by getParseData. | 
  | includeText | A logical value. | 
  | parseData | A data.frame returned by getParseData. | 
  | id | A vector of integers. | 
 
Details
The includeText argument specifies whether the data.frame produced
by getParseData contains the text for each of the parsed tokens.  
-  If includeText is TRUE, then the data.frame contains a column named
'text' with the text corresponding to each row.  
-  If includeText is FALSE, then the data.frame has no 'text' column.  
-  If includeText is NA, then there is a 'text' column, but it has only text
values for terminal tokens.
Value
| getParseData | returns a data.frame with one row for each of
the tokens in the parsed expression.  The data.frame columns are
the following: 
   "line1" Line number of the first character of the token text.
   "col1" Column number of the first character of the token text.
   "line2" Line number of the last character of the token text.
   "col2" Column number of the last character of the token text.
   "id" An integer identifying the token.
   "parent" The ID of the parent token of this token.
   "token" S string giving the token type.
   "terminal" A logical value, TRUE if the token has no children.
   "text" The text string for this token.  If the includeText
    argument is FALSE, this column is not present.
 | 
| getParseText | returns a vector of strings, giving the token
strings corresponding to the specified ID numbers. | 
 
See Also
Examples
ex <- parse(text="#comm1\nx<-function(x) {\n#comm2\n  x+1\n}\n",
            keep.source=TRUE)
pd <- getParseData(ex)
#    line1 col1 line2 col2 id parent          token terminal     text
# 1      1    1     1    6  1      0        COMMENT     TRUE   #comm1
# 20     2    1     5    1 20      0           expr    FALSE
# 3      2    1     2    1  3      4         SYMBOL     TRUE        x
# ...
getParseText(pd, 1)
# [1] "#comm1"