Class Parser


  • public class Parser
    extends java.lang.Object
    The Parser, just like the Generator, is a mess that is not meant to support the entirety of C++, but an appropriate subset as used by typical C/C++ header files. To figure out what that subset is and what the output should be, the idea is to apply it on as many C/C++ libraries as possible, and patch the code as we go. At one point in time, when this prototype code appears to have stabilized, we can start to redesign it in a more meaningful way.

    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.

    See Also:
    Info, InfoMap, InfoMapper
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.util.Map<java.lang.String,​java.util.Map<Type,​java.lang.Boolean>> downcasts
      Classes that have a base class appearing as a key in this map need a downcast constructor.
      (package private) java.lang.String encoding  
      (package private) InfoMap infoMap  
      (package private) InfoMap leafInfoMap  
      (package private) java.lang.String lineSeparator  
      (package private) Logger logger  
      (package private) java.util.Set<java.lang.String> polymorphicClasses
      Java names of classes recognized as polymorphic.
      (package private) java.util.Properties properties  
      (package private) TokenIndexer tokens  
      (package private) java.util.Set<java.lang.String> upcasts
      Java names of classes needing upcast from their subclasses.
    • Constructor Summary

      Constructors 
      Constructor Description
      Parser​(Logger logger, java.util.Properties properties)  
      Parser​(Logger logger, java.util.Properties properties, java.lang.String encoding, java.lang.String lineSeparator)  
      Parser​(Parser p, java.lang.String text)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void addDowncast​(java.lang.String base, Type from, boolean virtual)  
      (package private) Attribute attribute()  
      (package private) Attribute attribute​(boolean explicit)  
      (package private) java.lang.String body()  
      (package private) java.lang.String commentAfter()
      Converts Doxygen-like documentation comments placed after identifiers to Javadoc-style.
      (package private) java.lang.String commentBefore()
      Converts Doxygen-like documentation comments placed before identifiers to Javadoc-style.
      (package private) java.lang.String commentDoc​(java.lang.String s, int startIndex)
      Tries to adapt a Doxygen-style documentation comment to Javadoc-style.
      (package private) static java.lang.String constructorName​(java.lang.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, java.lang.String defaultName, int infoNumber, boolean useDefaults, int varNumber, boolean arrayAsPointer, boolean pointerAsArray)  
      (package private) static java.lang.String desugarVarargs​(java.lang.String s)  
      (package private) java.lang.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) 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 java.lang.String incorporateConstAnnotation​(java.lang.String annotations, int constValueIndex, boolean constValue)  
      (package private) boolean macro​(Context context, DeclarationList declList)  
      (package private) boolean namespace​(Context context, DeclarationList declList)  
      private java.lang.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)  
      java.io.File[] parse​(java.io.File outputDirectory, java.lang.String[] classPath, java.lang.Class cls)  
      java.io.File[] parse​(java.lang.String outputDirectory, java.lang.String[] classPath, java.lang.Class cls)  
      (package private) void parse​(Context context, DeclarationList declList, java.lang.String[] includePath, java.lang.String include, boolean isCFile)  
      (package private) static java.lang.String removeAnnotations​(java.lang.String s)  
      (package private) TemplateMap template​(Context context)  
      (package private) Type[] templateArguments​(Context context)  
      (package private) java.lang.String translate​(java.lang.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) java.lang.String upcast​(Type derived, Type base, boolean override)  
      (package private) static java.lang.String upcastMethodName​(java.lang.String javaName)  
      (package private) boolean using​(Context context, DeclarationList declList)  
      (package private) boolean variable​(Context context, DeclarationList declList)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • properties

        final java.util.Properties properties
      • encoding

        final java.lang.String encoding
      • lineSeparator

        java.lang.String lineSeparator
      • upcasts

        java.util.Set<java.lang.String> upcasts
        Java names of classes needing upcast from their subclasses.
      • downcasts

        java.util.Map<java.lang.String,​java.util.Map<Type,​java.lang.Boolean>> downcasts
        Classes that have a base class appearing as a key in this map need a downcast constructor. The associated value gives the class to downcast from and whether the inheritance is virtual.
      • polymorphicClasses

        java.util.Set<java.lang.String> polymorphicClasses
        Java names of classes recognized as polymorphic.
    • Constructor Detail

      • Parser

        public Parser​(Logger logger,
                      java.util.Properties properties)
      • Parser

        public Parser​(Logger logger,
                      java.util.Properties properties,
                      java.lang.String encoding,
                      java.lang.String lineSeparator)
      • Parser

        Parser​(Parser p,
               java.lang.String text)