C++ Parser (Front End)

The C++ parser (front end) enables the construction of C++ custom compilers, analysis tools, or source transformation tools. It is a member of SD's family of language front ends, based on first-class infrastructure (DMS) for implementing such custom tools. The C++ front end includes:

  • Full Lexical analysis
    • Characters sets include ASCII, ISO 8859-1, UTF-8, UTF-16, Shift-JIS and many other standard and Microsoft character encodings
    • Conversion of literal values (numbers, escaped strings) into native values to enable easy computation over literal values
    • String literals represented internally in Unicode to support 16-bit characters
  • Explicit grammar directly implements ISO/IEC 14882:1998 standard and C++11 (14882:2011 revised standard). It also implements all of C++14 (ISO/IEC 14882:2014).
    • Complete ANSI C++ parser
    • Option for Microsoft Visual6 C++ dialect
    • Option for Microsoft Managed C++ dialect
    • Option for Microsoft XBOX 360 C++ dialect
    • Option for Microsoft VS 2013 C++ dialect
    • Option for GNU C++ dialects (GCC2/GCC3/GCC4/GCC5.0 with vector extensions)
    • Option for SystemC 2.1
    • Pragma handling for OpenMP versions 2, 3, 4.5
  • Preprocessor support
    • Controllable include directory paths
    • Option to fully expand preprocessor directives
    • Option to parse include files for definitions
    • Option to parse preserving preprocessor conditional directives, macros and include directives
  • Automatic construction of complete abstract syntax tree
    • Capture of comments and formats (shape) of literal values
    • Capture of ambiguous parses during parsing
    • Ability to parse large systems of files into same workspace, enabling interprocedural and cross-file analysis/transformation
    • Ability to parse different languages into same workspace, enabling cross-language analysis/transformation
  • Facilities to process syntax trees
    • Complete procedural API to visit/query/update/construct/print syntax trees
    • Source regeneration by prettyprinting and/or fidelity printing of syntax trees with comments and lexical formats
    • Automatically generated source-to-source transformation system
    • Ability to define custom attribute-grammar-based analyzers
  • Name and Type resolution
    • Type representation system for all C++ types defined
    • All identifiers resolved to their C++-defined type and stored in symbol tables
    • Automatic deletion of erroneous alternatives of ambiguous parses
  • Control Flow Extraction
    • Includes constructors, destructors, (assignment) operators and user-defined conversions
    • Includes explicit throw, catch (but not yet implicit exceptions)
  • Function-level Data Flow Analysis
    • Use-def chains
    • Local must-alias analysis for pointers
  • Transformation
    • Mixed procedural (AST access/modification) or C++ syntax-based source-to-source rewrite rules
    • Ability to condition transforms on identifier type
    • Abilility to visit/query/update symbol tables
  • Flexibility
    • Complete access to underlying DMS capabilities
    • Means to manage multiple language dialects with highly shared common core
    • Available as source code to enable complete customization
    • Robustness due to careful testing and application across many customers

Many of these facilities come as a consistent consequence of the front end being built to top of DMS.

Here are some sample tools (many offered by SD as products) built using the C++ front end:

Your organization may use DMS with the C++ front end to implement and deploy your own custom tools. The sample tools can be obtained in source form as part of the C++ front end for customization. Semantic Designs is also willing to build custom tools under contract.

For more information: info@semanticdesigns.com    Follow us at Twitter: @SemanticDesigns

C++ Parser
Front End