parseTU | R Documentation |
These collection of functions are related to both parsing C or C++ source code and then iterating over the resulting parse tree and extracting information about the contents.
parseTU(src, visitor = simpleVisitor, idx = createIndex(),
tu = createTU(src, idx = idx, ...), ..., clone = FALSE)
createTU(src, includes = character(), idx = createIndex(verbose = verbose),
args = character(), verbose = getOption("ShowParserDiagnostics", TRUE),
options = 0)
visitCursor(tu, fun, clone = TRUE, data = NULL, ...)
getFile(tu, file_name)
defaultReparseOptions(TU)
isFileMultipleIncludeGuarded(tu, file)
src |
the fully-qualified name of the source code file |
visitor , fun |
a function that is called when iterating over the parse tree. This must return one of the CXChildVisit enumeration values. |
idx |
a |
includes |
a character vector specifying the paths to directories
in which the parser can look for |
args |
a character vector of flags or arguments for the
parser. These can include pre-processor definitions, e.g
|
verbose |
used when creating the index and controls whether diagnostic messages are written to the console. |
file |
a |
tu , TU |
a translation unit object. This is rarely specified by the caller. |
... |
additional parameters passed to |
clone |
a logical value controlling whether to clone the
|
options |
a collection of options that is a vector or bitwise
OR'ed together. The values come from the
|
file_name |
the name of the file for which we want a CXFile object |
data |
used in |
An integer value indicating whether the parsing was successful (0) or not (non-zero).
Duncan Temple Lang
libclang http://clang.llvm.org/doxygen/group__CINDEX.html
visitTU
createIndex
col = genFunctionCollector()
parseTU(system.file("exampleCode", "register.c", package = "RCIndex"),
col$update)
names(col$funcs())
# Illustrate using a compiled (C) routine as the visitor 'function'.
ff = system.file("exampleCode", "funPointer.c", package = "RCIndex")
routine = getNativeSymbolInfo("R_TestVisitor")$address
visitTU(ff, routine)
# Parse a C++ file.
f = system.file('exampleCode', 'simpleClass.cpp', package = 'RCIndex')
createTU(f, args = "-xc++")
# Get the pre-processor cursors
f = system.file("exampleCode", "macros.c", package = "RCIndex")
parseTU(f, options = RCIndex:::CXTranslationUnit_DetailedPreprocessingRecord)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.