Extending opC++ With Custom Dialects
Dialects in opC++ allow you to specify language extensions and how their syntax is generated into code.
Dialects are written in a simple C-style language - simply called the opC++ Dialect language.
opC++ uses dialects to allow you to easily create and share your own language extensions. By using opC++ Dialects, you can add language extensions, share them, and swap out extensions - all without libraries or complicated integration.
Add dialects to add features, it's that simple.
Learn more about opC++ Dialects here.
Extended C++ Syntax
opC++ always enables extended C++ syntax:
- public, private, protected modifiers
- uninline modifier - specify to output functions to generated source code.
Dialects in opC++ make it possible to extend the C++ language in many ways:
- category : class, struct, category
- modifier : const, volatile, modifier
- valued modifier : modifier(value)
- enumerations : enum, enumeration
- initialization : type x = ...;
In fact, Standard opC++ (Serialization, Reflection) is entirely written as an opC++ Dialect. The compiler first reads your dialects so that it knows how to parse your extended code. It then parses your opC++ code files and generates standard C++ code based on the code generation rules in your dialect files.
Simple Dialect File
Here we declare a new category called uclass, and generate a 'Super' typedef if a uclass declaration has single inheritance.
We generate the typedef in the class body via a note.
We can also pass many types of arguments from the category to the note.
Visual Studio Addin
opC++ comes with an addin to improve coding in Visual Studio.
Some of its features include:
- Easy access to compiler options.
- Automatically integrates compiling for opC++ code.
- Navigation between generated, dialect, and original code.
- Visualization of code and dialect output.
- Context menus for aiding dialect development.
You can learn more about the opC++ Visual Studio addin here.
Easily clean and compile opC++ code and access project settings.
Navigate between generated code, code and dialect files, and visualize your code all from the opC++ toolbar.