Category Archives: Code Samples

New code samples will be posted here.

Verbatim String Literals

I’m not that familiar with C#, but I found a nice feature when I was searching for other languages and how they process strings.

C# allows ‘verbatim’ strings, where it is very comfortable to enter file paths with the back-slash – as known in MS/Windows.

Here you can see how to write string literals in XièXiè :-D

// Standard (C++ like) string
string s1 := "\t\"\?"

// Verbatim (C# like) string
string s2 :=
    @"C:\Program Files\XieXie\Test.xx"

// Multi-line string
// (double quote will translate to "\"")
string s3 :=
    @"Hello ""XieXie"" programmer!"

The “flags” keyword

A very nice feature, I’ve already implemented, is the “flags” keyword. It’s similar to the “enum” keyword in common high-level languages.
But it automatically generates the values for each entry and has a namespace like the new C++11 “enum class” types.

In XièXiè you can write this:

flags ColorFlags {

And it will generate this C++ code:

//! ColorFlags flags enumeration.
struct ColorFlags
    // --- Auto-generated flags --- //
    typedef unsigned char DataType;
    static const DataType None  = 0;
    static const DataType All   = ~0;
    // --- Custom flags --- //
    static const DataType Red   = (1 << 0);
    static const DataType Green = (1 << 1);
    static const DataType Blue  = (1 << 2);