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)[source]

Bases: Exception

Raised when conversion cannot be done.

source on GitHub

source on GitHub

__init__(node, message, sofar, sostack)[source]

source on GitHub

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

Bases: antlr4.tree.Tree.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)[source]

constructor

Parameters
  • parser – parser used to parse the code

  • fLOG – logging function

source on GitHub

__str__()[source]

usual

source on GitHub

add_code(node)[source]

Converts one node into :epkg:`python`.

source on GitHub

add_code_final()[source]

Adds extra characters if needed.

source on GitHub

empty_stack()[source]

Empties the stack.

source on GitHub

enterEveryRule(ctx)[source]

event

source on GitHub

enterIntersections(ctx: pyensae.languages.RParser.RParser.RangesContext)[source]

event

source on GitHub

enterRanges(ctx: pyensae.languages.RParser.RParser.RangesContext)[source]

event

source on GitHub

exitEveryRule(ctx)[source]

event

source on GitHub

exitIntersections(ctx: pyensae.languages.RParser.RParser.RangesContext)[source]

event

source on GitHub

exitRanges(ctx: pyensae.languages.RParser.RParser.RangesContext)[source]

event

source on GitHub

fLOG(*l, **p)[source]

logging

source on GitHub

get_python()[source]

Get the Python code for the R code.

Returns

Python code

source on GitHub

has_parent(current, parent, depth=None)[source]

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)[source]

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)[source]

Converts a terminal node into a rule name.

source on GitHub

to_python(name, node)[source]

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

source on GitHub

visitErrorNode(node)[source]

event

source on GitHub

visitTerminal(node)[source]

event

source on GitHub