Code Monkey home page Code Monkey logo

zero-preprocessor's Introduction

Zero Preprocessor

A cross-platform cross-compiler source to source translator that will allow us to play around with some new compile time language features such as Static Reflection and Meta Classes. The AST can also be used for building static analysers.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for testing purposes.

Prerequisites

A prerequisite for this project is Boost 1.67+ specifically Boost.Spirit x3 and Boost.Process

Installing

For now all you need to do is git clone the repo, add it as a sub_directory and call the function on the target you wish to include the preprocessor for.

# add our preprocessor
set(preprocessor_dir "path/to/cloned/repo")

# where to build it relative to your project build dir or an absolute path
set(preprocessor_build_dir "./preprocessor_build")
add_subdirectory(${preprocessor_dir} ${preprocessor_build_dir} EXCLUDE_FROM_ALL)

# preprocess our example target
preprocess(example ${preprocessor_dir})

Tested on GCC 7.3, 8.3, 9.2; Clang 6.0, 7.0, 9.0 and MSVC 15.9

Also beware of the Clang + libstdc++ std::variant bug.

Examples

Full examples of usages of the implemented features are located in the examples folder.

Versioning

The project does not use versioning for now, as you should always build from the master branch.

TODOs

Things left to be implemented

Meta Classes

  • Parsing of meta classes in code
  • generator -> in constexpr function
  • get class functions
  • -> variable.method()$ in {}
  • -> (variable)$ in {}
  • multiple files
  • -> with target function
  • get class variables
  • compiler.require
  • method access modifier status e.g. is_public()
  • constructors is_copy() is_move()
  • constructors/destructors status
  • compiler.error
  • compiler.require/error with f to display source location
  • propagate method's const and && qualifiers
  • class and method templates
  • __metaclass_finalization
  • AS & IS
  • use of normal user constexpr functions inside metaclass functions
  • add concepts

Static Reflection

  • reflexpr()
  • reflect::get_name
  • reflect::get_display_name will wait for C++20
  • reflect::get_type
  • reflect::get_reflected_type
  • reflect::is_[enum, class, struct, union]
  • reflect::get_public_data_members
  • reflect::get_size and reflect::get_element
  • reflect::get_pointer (for data members)
  • reflect::get_data_members
  • reflect::get_public_base_classes
  • reflect::get_base_classes
  • reflect::get_accessible_[data_members, base_classes] based on context
  • reflect::is_final & reflect::is_virtual
  • enum operations
  • reflect::get_constant for enumerator values
  • reflexpr() for variables and namespaces
  • reflect::is_inline for namespaces
  • add concepts

Parser:

  • variables
  • expressions
  • functions
  • struct/class
  • methods and data members
  • constructors/destructors
  • virtual/override methods
  • C style arrays
  • index operator
  • new/delete malloc/free
  • for loop and ranged base for
  • while loop and else
  • type templates
  • non-type templates
  • variadic templates
  • explicit/partial class template specialization
  • user defined class template deduction guide
  • Inheritance
  • virtual inheritance
  • if constexpr
  • namespaces
  • C++17 namespaces n1::n2
  • enum
  • union
  • constexpr functions
  • lambdas
  • C++17 structured binding declaration
  • C++14 functions with -> return type

Contributing

There are TODO comments throughout the project. Before starting to fix one please open an issue referencing the TODO in code.

License

This project is licensed under the Apache License 2.0 License - see the LICENSE file for details

zero-preprocessor's People

Contributors

oborce avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

blockspacer

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.