parsetools (version 0.1.1)

iff-blocks: IFF Blocks

Description

IFF is short for if(FALSE){#@tag ... blocks. These block can contain development, testing, or example code that can be extracted into documentation or other files.

Usage

pd_is_iff(id, pd, allow.short = TRUE, .check = TRUE)

pd_is_iff_block(id, pd, allow.short = TRUE, .check = TRUE)

pd_all_iff_ids(pd = get("pd", parent.frame()), ...)

pd_all_iff_block_ids(pd, root.only = TRUE, ignore.groups = FALSE, ...)

pd_is_tagged_iff_block(id, pd, tag, doc.only = TRUE, ..., .check = TRUE)

Arguments

id

id of the expression of interest

pd

The parse-data information

allow.short

if if(F) should be considered an IFF block.

.check

Perform checks for input validation?

...

passed along.

root.only

only root blocks(TRUE) or all block (FALSE)

ignore.groups

Ignore code grouping

tag

The tag to consider.

doc.only

Should comments be restricted to documentation style comments only?

Functions

  • pd_is_iff: This function tests if an expression id is the root of an if(FALSE) statement, differs from pd_is_iff_block in that it will return TRUE even if the conditional statement is not a formal bracketed block {...}.

  • pd_is_iff_block: Tests if an expression id is the root of an if(FALSE) block statement, differs from pd_is_iff in that in addition to it being an if(FALSE) expression the conditional branch of the logic must be a braced block of code. E.g. if given the id corresponding to if(FALSE){...}, both pd_is_iff() and pd_is_iff_block() would return TRUE while for if(FALSE)do_somthing() pd_is_iff() would return TRUE but pd_is_iff_block() would return FALSE because the expression is not a 'block' statement.

  • pd_all_iff_ids: Get all ids corresponding to IFF expressions.

  • pd_all_iff_block_ids: Get all ids corresponding to IFF block

  • pd_is_tagged_iff_block: Test if a block if both an IFF block statement and is tagged. To tag an IFF block the first pared element must be a comment that contains an '@' tag to denote a special block. The comment on the same line as the opening brace or on any subsequent line but cannot be preceded by any other statement.

Details

Here are some examples:

  • if(FALSE){#' @test ... Is valid and tags the block as a test.

  • if(FALSE){#@test ... Is valid and tags the block as a test. Note here that we are using the #@ tag comment.

  • if(FALSE){# @test ... Is valid only if doc.only==FALSE.

  • if(FALSE)#@test ...