public class Parser extends Object
That said, to understand how it is supposed to function in its present state, one can step through the code at runtime: It is quite friendly to debuggers.
Moreover, it relies on Info
objects created as part of the execution
of InfoMapper.map(InfoMap)
. We can understand better how the parsing
is supposed to get accomplished by studying that documentation as well.
To do: - Inherit constructors from helper classes, if possible - etc.
Info
,
InfoMap
,
InfoMapper
Modifier and Type | Field and Description |
---|---|
(package private) Map<String,Map<Type,Boolean>> |
downcasts
Classes that have a base class appearing as a key in this map need a downcast constructor.
|
(package private) String |
encoding |
(package private) InfoMap |
infoMap |
(package private) InfoMap |
leafInfoMap |
(package private) String |
lineSeparator |
(package private) Logger |
logger |
(package private) Set<String> |
polymorphicClasses
Java names of classes recognized as polymorphic.
|
(package private) Properties |
properties |
(package private) TokenIndexer |
tokens |
(package private) Set<String> |
upcasts
Java names of classes needing upcast from their subclasses.
|
Constructor and Description |
---|
Parser(Logger logger,
Properties properties) |
Parser(Logger logger,
Properties properties,
String encoding,
String lineSeparator) |
Parser(Parser p,
String text) |
Modifier and Type | Method and Description |
---|---|
(package private) void |
addDowncast(String base,
Type from,
boolean virtual) |
(package private) Attribute |
attribute() |
(package private) Attribute |
attribute(boolean explicit) |
(package private) String |
body() |
(package private) String |
commentAfter()
Converts Doxygen-like documentation comments placed after identifiers to Javadoc-style.
|
(package private) String |
commentBefore()
Converts Doxygen-like documentation comments placed before identifiers to Javadoc-style.
|
(package private) String |
commentDoc(String s,
int startIndex)
Tries to adapt a Doxygen-style documentation comment to Javadoc-style.
|
(package private) static String |
constructorName(String cppName)
Constructors have 2 kinds of fully qualified name:
the calling name of a constructor, used when calling the constructor, e.g.:
NS::CN(int)
and the declaration name, used when defining the constructor outside its class or when referencing a constructor
with using to inherit constructors of base class.
|
(package private) void |
containers(Context context,
DeclarationList declList) |
(package private) void |
declarations(Context context,
DeclarationList declList) |
(package private) Declarator |
declarator(Context context,
String defaultName,
int infoNumber,
boolean useDefaults,
int varNumber,
boolean arrayAsPointer,
boolean pointerAsArray) |
(package private) static String |
desugarVarargs(String s) |
(package private) String |
downcast(Type derived,
Type base,
boolean virtual) |
(package private) boolean |
enumeration(Context context,
DeclarationList declList) |
(package private) boolean |
extern(Context context,
DeclarationList declList) |
(package private) static String |
filterJavaAnnotations(String s) |
(package private) boolean |
function(Context context,
DeclarationList declList) |
(package private) Type |
functionAfter(Context context,
Declaration decl,
Declarator dcl,
Type type)
Parse function declaration or definition after parameters:
const, attributes, trailing type, pure virtual functions.
|
(package private) boolean |
group(Context context,
DeclarationList declList) |
(package private) static String |
incorporateConstAnnotation(String annotations,
int constValueIndex,
boolean constValue) |
(package private) boolean |
macro(Context context,
DeclarationList declList) |
(package private) boolean |
namespace(Context context,
DeclarationList declList) |
private String |
operator(Context context)
Read and return the operator following an operator keyword:
any of
new, delete, + - * / % ^ & | ~ ! = < > += -= *= /= %= ^= &= |= << >> >>= <<= == != <= >= <=>(since C++20) && || ++ -- , ->* -> ( ) [ ]
taking care of template arguments, if any. |
(package private) Parameters |
parameters(Context context,
int infoNumber,
boolean useDefaults) |
(package private) void |
parse(Context context,
DeclarationList declList,
String[] includePath,
String include,
boolean isCFile) |
File[] |
parse(File outputDirectory,
String[] classPath,
Class cls) |
File[] |
parse(String outputDirectory,
String[] classPath,
Class cls) |
(package private) static String |
removeAnnotations(String s) |
(package private) static String[] |
removeDuplicates(String[] a)
De-deduplicate an array of strings, keeping order.
|
(package private) TemplateMap |
template(Context context) |
(package private) Type[] |
templateArguments(Context context) |
(package private) String |
translate(String text) |
(package private) Type |
type(Context context) |
(package private) Type |
type(Context context,
boolean definition) |
(package private) boolean |
typedef(Context context,
DeclarationList declList) |
(package private) String |
upcast(Type derived,
Type base,
boolean override) |
(package private) static String |
upcastMethodName(String javaName) |
(package private) boolean |
using(Context context,
DeclarationList declList) |
(package private) boolean |
variable(Context context,
DeclarationList declList) |
final Logger logger
final Properties properties
final String encoding
InfoMap infoMap
InfoMap leafInfoMap
TokenIndexer tokens
String lineSeparator
Map<String,Map<Type,Boolean>> downcasts
public Parser(Logger logger, Properties properties)
public Parser(Logger logger, Properties properties, String encoding, String lineSeparator)
static String[] removeDuplicates(String[] a)
static String constructorName(String cppName)
void containers(Context context, DeclarationList declList) throws ParserException
ParserException
TemplateMap template(Context context) throws ParserException
ParserException
Type[] templateArguments(Context context) throws ParserException
ParserException
private String operator(Context context) throws ParserException
new, delete, + - * / % ^ & | ~ ! = < > += -= *= /= %= ^= &= |= << >> >>= <<= == != <= >= <=>(since C++20) && || ++ -- , ->* -> ( ) [ ]
taking care of template arguments, if any.ParserException
Type type(Context context) throws ParserException
ParserException
Type type(Context context, boolean definition) throws ParserException
ParserException
Declarator declarator(Context context, String defaultName, int infoNumber, boolean useDefaults, int varNumber, boolean arrayAsPointer, boolean pointerAsArray) throws ParserException
ParserException
String commentDoc(String s, int startIndex)
String commentBefore()
String commentAfter()
Attribute attribute()
Attribute attribute(boolean explicit)
String body() throws ParserException
ParserException
Parameters parameters(Context context, int infoNumber, boolean useDefaults) throws ParserException
ParserException
static String incorporateConstAnnotation(String annotations, int constValueIndex, boolean constValue)
boolean function(Context context, DeclarationList declList) throws ParserException
ParserException
Type functionAfter(Context context, Declaration decl, Declarator dcl, Type type) throws ParserException
ParserException
boolean variable(Context context, DeclarationList declList) throws ParserException
ParserException
boolean macro(Context context, DeclarationList declList) throws ParserException
ParserException
boolean typedef(Context context, DeclarationList declList) throws ParserException
ParserException
boolean using(Context context, DeclarationList declList) throws ParserException
ParserException
boolean group(Context context, DeclarationList declList) throws ParserException
ParserException
boolean enumeration(Context context, DeclarationList declList) throws ParserException
ParserException
boolean namespace(Context context, DeclarationList declList) throws ParserException
ParserException
boolean extern(Context context, DeclarationList declList) throws ParserException
ParserException
void declarations(Context context, DeclarationList declList) throws ParserException
ParserException
void parse(Context context, DeclarationList declList, String[] includePath, String include, boolean isCFile) throws IOException, ParserException
IOException
ParserException
public File[] parse(String outputDirectory, String[] classPath, Class cls) throws IOException, ParserException
IOException
ParserException
public File[] parse(File outputDirectory, String[] classPath, Class cls) throws IOException, ParserException
IOException
ParserException
Copyright © 2024. All rights reserved.