Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

parser_version_set

Work with parser versions


Description

The structure of the parse data affects many operations in styler. There was unexpected behavior of the parser that styler was initially designed to work around. Examples are #187, #216, #100 and others. With #419, the structure of the parse data changes and we need to dispatch for older versions. As it is inconvenient to pass a parser version down in the call stack in various places, the environment env_current is used to store the current version globally but internally.

Usage

parser_version_set(version)

parser_version_get()

parser_version_find(pd)

Arguments

version

The version of the parser to be used.

pd

A parse table such as the output from utils::getParseData(parse(text = text)).

Details

We version the parser as follows:

  • version 1: Before fix mentioned in #419.

  • version 2: After #419.

version 3: After #582.

The following utilities are available:

  • parser_version_set() sets the parser version in the environment env_current.

  • parser_version_get() retrieves the parser version from the environment env_current.

  • parser_version_find() determines the version of the parser from parse data. This does not necessarily mean that the version found is the actual version, but it behaves like it. For example, code that does not contain EQ_ASSIGN is parsed the same way with version 1 and 2. If the behavior is identical, the version is set to 1.


styler

Non-Invasive Pretty Printing of R Code

v1.4.1
MIT + file LICENSE
Authors
Kirill Müller [aut], Lorenz Walthert [cre, aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.