Parser {tangram} | R Documentation |
The parser class for generating abstract syntax trees for given table formulas.
Description
The parser class for generating abstract syntax trees for given table formulas.
The parser class for generating abstract syntax trees for given table formulas.
Format
R6Class
object.
References
Aho, A. V., Lam, M. S., Sethi, R., and Ullman, J. D. (2006) Compilers: Principles, Techniques, and Tools, 2nd edition. Addison Wesley.
Public fields
input
Storage for input string of a formula
pos
The current parsing position
len
The length of the input
Methods
Public methods
Method new()
Create a parser
Usage
Parser$new()
Method expect()
Specify expectation of next token from lexer
Usage
Parser$expect(id)
Arguments
id
The token id expected in stream, otherwise it's an error
Method peek()
Peek at the next token from parser
Usage
Parser$peek()
Method eat_whitespace()
Remove white space to find start of next token
Usage
Parser$eat_whitespace()
Method next_token()
Returns next lexical token
Usage
Parser$next_token()
Method format()
Return format string as token from lexical stream
Usage
Parser$format()
Method r_expression()
Return R expression as token from lexical stream
Usage
Parser$r_expression()
Method factor()
Return next factor as token.
Usage
Parser$factor()
Method term()
Parse and return next term in stream
Usage
Parser$term()
Method expression()
Parse and return next expression in stream
Usage
Parser$expression()
Method table_formula()
Parse and return table formula from stream
Usage
Parser$table_formula()
Method run()
Run the parser
Usage
Parser$run(x)
Arguments
x
(character,formula) The table specification to parse
Method clone()
The objects of this class are cloneable with this method.
Usage
Parser$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
Parser$new()$run("col1 + col2 + col3 ~ drug*age+spiders")