Description Usage Arguments Value Note Author(s) References See Also Examples
This is a parser for R code using the same grammar as the
usual parser (parse
) but structuring the
information differently.
1 |
file |
Source file to parse |
encoding |
Encoding for the file |
text |
If |
The output is a list of expressions similar to the output
of parse
except that expressions are not
associated with an inline srcref
information.
Instead, each expression has an id
attribute that
refers to the data.
The data
attribute is a data frame with the
following columns:
line1,col1,byte1 |
First line, column, and byte of the symbol (token or expression) |
line2,col2,byte2 |
Last line, column, and byte of the symbol (token or expression) |
token |
Token type. |
id |
Unique identifier given to this token or expression |
parent |
identifier for the expression that contains this token or expression |
token.desc |
A description of this token type. This is read from the output generated by bison |
The location information is different to that of R's
parse
function, parse
structures columns and bytes information to comply with
the substring
function whereas this
function returns the information as an offset to the
start of the line.
Romain Francois <romain@r-enthusiasts.com>
This function is largely inspired from the R core
parse
function. The C code uses the same
grammar as the one used by parse
.
The Gnu bison parser generator (http://www.gnu.org/software/bison/) is used to create the C code from the grammar.
The usual R parser parse
1 2 | f <- system.file( "example", "f.R", package = "parser" )
out <- parser( f )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.