Skip to content

Instantly share code, notes, and snippets.

@blockspacer
Last active March 31, 2021 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blockspacer/6f03933de4f9a6c920649713b056ba4a to your computer and use it in GitHub Desktop.
Save blockspacer/6f03933de4f9a6c920649713b056ba4a to your computer and use it in GitHub Desktop.
Parse C++
@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

blockspacer commented Aug 23, 2019

**In this example we use SDL2 to create a window and we reload the logic code when F9 is pressed. + JavaScript target **
https://nim-lang.github.io/Nim/hcr
https://nim-lang-cn.org/docs/hcr.html

Nim - the first high performance language with full support for hot code-reloading at runtime
https://slides.com/onqtam/nim_hot_code_reloading#/

Nim procs to C/C++
https://slides.com/onqtam/nim_hot_code_reloading#/26

https://github.com/nim-lang/Nim/issues/8927#issuecomment-486235979

https://github.com/status-im/nim-serialization

https://github.com/3dicc/Urhonimo

https://github.com/PhilipWitte/NimQt

nim-lang/Nim#8327

https://github.com/nimterop/nimterop

arnetheduck/nlvm@6c0de4b

https://www.spiria.com/en/blog/web-applications/webassembly-nim/

nim-lang/Nim#8713

A new compiler option --cppCompileToNamespace puts the generated C++ code into the namespace “Nim” in order to avoid naming conflicts with existing C++ code. This is done for all Nim code - internal and exported.

https://www.youtube.com/watch?v=JMkEJ__2Meg
https://nim-lang.org/talk01/slides.html#(8)
Nimrod compiles to C; C++ and Objective-C are also supported

Nim without GC
https://nim-lang.org/araq/destructors.html

Nim language aspects, that I don't learn to like
https://forum.nim-lang.org/t/2111

@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

blockspacer commented Aug 23, 2019

ExtendedCPP is a c++ parser using parser-toolkit. It allows to extend c++ language features by transpiling
https://github.com/reneeichhorn/extended-cpp/blob/463429ce697c8c20290e56115c735b45b16f9bb4/specifications/modules.md
https://github.com/reneeichhorn/extended-cpp

@blockspacer
Copy link
Author

BXCPP is a bidirectional preprocessor for C/CPP language based on an open source project JCPP.
https://github.com/harouwu/BXCPP

@blockspacer
Copy link
Author

https://research-information.bristol.ac.uk/files/142141947/%7C
Un-preprocessing: Extended CPP that works with your tools∗

@blockspacer
Copy link
Author

blockspacer commented Aug 24, 2019

@blockspacer
Copy link
Author

A clean implementation of reflection and related proposals. https://github.com/asutton/clang-reflect

@blockspacer
Copy link
Author

Building a C++ Reflection System in One Weekend Using Clang and LLVM - Arvid Gerstmann
https://www.youtube.com/watch?v=XoYVeduK4yI
https://github.com/leandros/metareflect Metareflect is a lightweight reflection system for C++, based on LLVM and Clangs libtooling. https://arvid.io

@blockspacer
Copy link
Author

YVR18-223:How to build a C processing tool using the Clang libraries
https://connect.linaro.org/resources/yvr18/sessions/yvr18-223/

@blockspacer
Copy link
Author

blockspacer commented Aug 24, 2019

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0707r0.pdf
A Clang-based prototype is available at github.com/asutton/clang (source) and cppx.godbolt.org (live compiler).
https://ghjang.github.io/computer%20programming/2017/08/10/building_prototype_clang_for_metaclass.html

@blockspacer
Copy link
Author

blockspacer commented Aug 24, 2019

https://www.youtube.com/watch?v=VynWyOIb6Bk
This is an experience report of the Clang-based implementation of Herb Sutter's Lifetime safety profile for the C++ Core Guidelines, available online at cppx.godbolt.org.
https://ghjang.github.io/computer%20programming/2017/08/10/building_prototype_clang_for_metaclass.html

@blockspacer
Copy link
Author

blockspacer commented Aug 24, 2019

Circle-lang. Metaprogram C++ in C++. Now for download.
https://www.reddit.com/r/cpp/comments/bpxwqv/circlelang_metaprogram_c_in_c_now_for_download/

It's designed totally differently from metaclasses. Metaclasses require a very fine-grained object-oriented API which is supposed to model all aspects of the language. You use this API from inside the metaclass to modify the type.

The reflection in Circle has no API at all. You simply do compile-time control flow by putting @meta in front of control flow statements to cause them to go at compile time, and declare your members inside of that. It's all done contextually. If the innermost scope is a namespace, then the real statement inside your meta for will be treated like any other statement inside a namespace scope. If the innermost scope is a class definition, then the real statement will be treated like a member-specifier, and so on.

Circle is very Keep-It-Simple-Stupid. That's really the best principal in software design; I feel C++20 and the future proposals have given up on that.

@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

Метапрограммирование в C++ и русская литература: через страдания к просветлению

https://habr.com/ru/article/448466/

@blockspacer
Copy link
Author

@blockspacer
Copy link
Author

@YahyaAbraheem
Copy link

Thank you for such great resources. Now, how we can get the control flow graph based on the parser you have built using Bison and Flex? Then we should extract a control flow graph to do further analysis such as reaching definitions or liveness of a variable. Do you have resources for that as well?

@blockspacer
Copy link
Author

Thank you for such great resources. Now, how we can get the control flow graph based on the parser you have built using Bison and Flex? Then we should extract a control flow graph to do further analysis such as reaching definitions or liveness of a variable. Do you have resources for that as well?

I use Clang LibTooling in https://github.com/blockspacer/CXXCTP . I don't use Bison or Flex

About Control Flow in Clang:

@YahyaAbraheem
Copy link

Thank you, have you implemented worklist iterative algorithm for data flow analysis in Clang that will work based on reaching definitions, kill and gen sets?

@blockspacer
Copy link
Author

data flow analysis in Clang

No.

May be useful:

@blockspacer
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment