CM Syntax - Introduction

Updated: Jul 27, 2021

Hey! How's it going?!

I'm glad to see you're still interested and want to learn more. In this post, we will uncover one of - to me at least - the most interesting aspects of CM: Syntax Extensions.

If you are familiar with languages such as Lisp (Lisp's Macros are especially fun and powerful when compared to the others in this list), Python, C++, and Boo (or to a lesser degree, the .Net platform) you might already have leveraged the preprocessor's capabilities beyond the "standard" language specification into the realm of meta-programming.

The key aspect here is to be able to expand the SLE for whatever platform you are working on into something that fits your requirements in a more efficient and/or friendly manner.

You can potentially use this capability to:

  • Create a DSL to better map the code to the business jargon of your project;

  • Add new features to the underlying GPL you are working with;

  • Create templates to reduce code redundancy;

Hello Syntax

Without further ado, I think it's time for us to get to work and create our first CM Syntax Extension (which from now on I'll refer to simply as CSE).

There are several different "types" of syntax structures in CM. You can find them all just by searching for “extends Syntax” inside the base CM repository.