module languages.rconverterListener

Inheritance diagram of pyensae.languages.rconverterListener

Short summary

module pyensae.languages.rconverterListener

Convert R into Python

source on GitHub

Classes

class

truncated documentation

R2PyConversionError

Raised when conversion cannot be done.

TreeStringListener

This class is an attempt to run through the tree and convert it into a string.

Methods

method

truncated documentation

__init__

__init__

constructor

__str__

usual

add_code

Converts one node into :epkg:`python`.

add_code_final

Adds extra characters if needed.

empty_stack

Empties the stack.

enterEveryRule

event

enterIntersections

event

enterRanges

event

exitEveryRule

event

exitIntersections

event

exitRanges

event

fLOG

logging

get_python

Get the Python code for the R code.

has_parent

Tells if parent is one of the parents of current.

search_parents

Searches for a substring in parents’ node name.

terminal_node_name

Converts a terminal node into a rule name.

to_python

Converts a couple (name, node) into :epkg:`Python`.

visitErrorNode

event

visitTerminal

event

Documentation

Convert R into Python

source on GitHub

exception pyensae.languages.rconverterListener.R2PyConversionError(node, message, sofar, sostack)

Bases: Exception

Raised when conversion cannot be done.

source on GitHub

source on GitHub

__init__(node, message, sofar, sostack)

source on GitHub

class pyensae.languages.rconverterListener.TreeStringListener(parser, fLOG=None)

Bases: ParseTreeListener

This class is an attempt to run through the tree and convert it into a string.

source on GitHub

constructor

Parameters:
  • parser – parser used to parse the code

  • fLOG – logging function

source on GitHub

__init__(parser, fLOG=None)

constructor

Parameters:
  • parser – parser used to parse the code

  • fLOG – logging function

source on GitHub

__str__()

usual

source on GitHub

add_code(node)

Converts one node into :epkg:`python`.

source on GitHub

add_code_final()

Adds extra characters if needed.

source on GitHub

empty_stack()

Empties the stack.

source on GitHub

enterEveryRule(ctx)

event

source on GitHub

enterIntersections(ctx)

event

source on GitHub

enterRanges(ctx)

event

source on GitHub

exitEveryRule(ctx)

event

source on GitHub

exitIntersections(ctx)

event

source on GitHub

exitRanges(ctx)

event

source on GitHub

fLOG(*l, **p)

logging

source on GitHub

get_python()

Get the Python code for the R code.

Returns:

Python code

source on GitHub

has_parent(current, parent, depth=None)

Tells if parent is one of the parents of current.

Parameters:
  • current – current node

  • parent – parent to look for

Returns:

boolean

source on GitHub

search_parents(node, substring, max_depth=None)

Searches for a substring in parents’ node name.

Parameters:
  • node – current node

  • substring – substring to search

  • max_depth – number of parents to look at

Returns:

boolean

source on GitHub

terminal_node_name(node)

Converts a terminal node into a rule name.

source on GitHub

to_python(name, node)

Converts a couple (name, node) into :epkg:`Python`.

source on GitHub

visitErrorNode(node)

event

source on GitHub

visitTerminal(node)

event

source on GitHub