Tangent's Blog

CharaChorder and Forge related articles and notes

TanChord Code Library (TCCL) language reference

Introduction

TanChord Code Library (TCCL) language is a language used to describe a chord library in TanChord Code (TC Code) editor. This reference will explain the language’s syntax.

It’s recommended to read the chords page in the official CharaChorder document and know about “chord”, “chord input”, “chord output”, and “chord notation” before reading this language reference.

Key Notation

The fundamental element of chord input and chord output is a key. In this section, I will explain how to describe keys in TCCL.

For English letters (upper and lowercase), numbers, and a few supported symbols, you can directly use the character itself to specify the corresponding key on the QWERTY OS layout (or corresponding CCOS action code). For example, b is the b key, 2 is the 2 key, and / is the / key.

In the chord output, the space character is the right space key, but you cannot use this character at chord input.

For other keys or actions, you can use the CCOS action code number enclosed in angle brackets to specify any of them. For example, <558> is the action that activates a dynamic library, and <559> is the action that returns to the base library.

Below is a table of these keys for reference.

TypeSyntaxExampleRemark
Letter Key[a-zA-Z]a, A , b
Number key[0-9]1, 2, 3
Symbol key[, ], ., /, -[, -
(Right) Space key It can only be used in chord output.
Action code<ACTION_CODE_NUMBER><558>, <559>

Chord Notation

Next, we will learn how to describe a chord.

First, let’s look at a simple example. Here is a chord whose input keys are b and c, and its output is because.

1
b + c = because

Similar to the chord notation defined in the official CharaChorder document, we use + to separate the input keys and use = to separate the input and output. The spaces around + and = are necessary to make it more readable and easier to be parsed. The chord output is just a series of keys without any separator.

So the general syntax of a chord can be described as:

1
K + K + ... = KK...

, where you can replace any K with any key notation defined above.

Chord Library

A TCCL file describes a whole chord library. Each non-empty line is a chord notation that represents a chord. An empty line is required at the end of the file.

Let’s take sample 1 from the TC Code editor as an example.

1
2
3
4
5
6
b + c = because
y + o + u = you
b + a + k = back
d + o + w + n = down
i + m + p = important

It is a chord library with five chords.

Compound Chord and Dynamic Chord Library

ℹ️ Dynamic chord library activation chord is a special kind of compound parent chord that will hold its input in the background, so you can access its children chord after it is activated. TCCL uses the same way to describe them.

In the official CharaChorder document, the pipe symbol (|) is used to separate sequential chord inputs in a compound chord. For example, w + b + s + t | c + h + a + r = www.charachorder.com means you need to chord w+b+s+t and then chord c+h+a+r, to get the output “www.charachorder.com”.

That format is good when you only describe a compound chord. But for a chord library, there may be many redundancies when multiple compound chords share the same ancestor(s), or many chords under a dynamic chord library. For example,

1
2
3
4
5
6
7
// PAY ATTENTION! This is NOT the syntax of TCCL!
s + m = some
s + m | t + g = something
s + m | b + o = somebody
s + m | o + n = someone
s + v = several

So in TCCL, inspired by languages such as Python and YAML, indentation is used to specify the parent-child relationships between chords. For example, the TCCL file describing the chord library above would be:

1
2
3
4
5
6
s + m = some
t + g = something
b + o = somebody
o + n = someone
s + v = several

And here is another example, the sample 3 of TC Code. It has a dynamic chord library, lib1, a chord for returning to the base library, and a chord a + r = arm under the lib1.

1
2
3
4
i + l = <559>base
l + r = <558>lib1
a + r = arm

Regarding indentation size, using two spaces is recommended, and it’s also the default setting in TC Code.

Conclusion

That’s all you need to know to code your chord library in TCCL language. TCCL language aims to be a convenient and straightforward way to describe chord libraries. Thanks for your reading!