*.clp *.clpl
CLPL [Si-El-Pi-El
]
Chamaelyn Key-Value Pair Language [Sha-Ma-E-Lin Qi-Va-Luy Pe-Ir Le-Ngu-Ej
]
ℹ️ May be used as a storage for storing information, data, or even lists.
CLPL is a key-value pair based language for data.
⚠️ Keys are case-sensitive.
name >
first-name = 'Andrew'
family-name = 'Pablo'
<
@country=1
@area=415
phone = 732_3156
job = [
'Teacher'
'Driver'
]
address = (
country = 'USA'
state = 'California'
city = 'San Fransisco'
)
email + (
id = 'andrew1email135'
domain = 'ymail.com'
)
email + (
id = 'andrew2email531'
domain = 'gmail.com'
)
Each value has each own type which will explained below:
None
type refer to something that doesn't exist.
This can refer to thing that may exist on other pair, but doesn't exist on current pair.
None
is written as none
Example:
family + (
name = 'Bob'
# Bob has a phone number
phone = '+1 (213) 653-5325'
)
family + (
name = 'Poppy'
# Poppy doesn't have a phone number
phone = none
)
Boolean
type refer to a thing that are either true or false
Boolean
can be written either as yes
or no
Example:
family + (
name = 'Bob'
# Bob has a phone number
has-phone = yes
)
family + (
name = 'Poppy'
# Poppy doesn't have a phone number
has-phone = no
)
Number
type refer to some numbers in double-precision
with decimals support
Example:
cash = 1225
Number can be separated with _
as following:
cash = 1_225
Number may contain decimals
cash = 1_225.20
Text
type refer to a text value
Example:
description = 'A text'
Split text to another line:
description = 'A text
split to another line'
Use \
at the end of previous line to prevent trailing spaces:
description = 'A text\
split to\
another line'
Text
type has two sub-types which will be explained below:
A single quote text will escape all the escape characters,
except for escaping '
itself and trailing spaces
Example:
description = 'This won\'t made a\nnew line\nat the text'
Will be parsed to
This won't made a\\nnew line\\nat the text
Instead of
This won't made a
new line
at the text
A double quote text will parse the escape characters
Supported escape characters:
Character | Description |
---|---|
\' | Single Quote |
\" | Double Quote |
\\ | Backslash |
\n | New Line |
\r | Carriage Return |
\t | Horizontal Tab |
\b | Backspace |
\f | Form Feed |
\v | Vertical Tab |
\uFFFF | Character represent by hexadecimal from "0000" to "FFFF" |
Example:
description = "This will made a\nnew line\nat the text"
description = "This will made a\n
new line\n
at the text"
description = "This will made a\n\
new line\n\
at the text"
Will be parsed to:
This will made a
new line
at the text
List
type refer to a list of values
List
type may refer to a pair which contain more than one values
Example:
text = [
'First text'
'Second text'
]
May also add another value without doing it from the pair
text + 'Third text'
text + 'Fourth text'
text + 'Fifth text'
Pairs
type are referring to a group of key-value pair
Pairs
type are the top-level type in CLPL
Example:
profile = (
name = 'Joe'
have-job = yes
)
May also modify the pairs without doing it from the pair
# {
# name: 'Joe',
# 'have-job': true,
# job: 'Engineer',
# email: '[email protected]'
# }
profile >
job = 'Engineer'
email = '[email protected]'
<
BigInt
type refer to some numbers in int64
BigInt
may be written as <number>n
Example:
id = 918378257521442816n
With separator:
id = 918378257521_442_816n
Annotation
may be used as a notes separated from the value
Annotation
may still be parsed
Annotation
is written as @<name>
Assigning value to Annotation
may done by doing @<name>=<value>
Annotation
without value is the same as assigning Annotation
with None
Example:
@for='Joe'
@domain='ymail.com'
email + 'joemail'
@for='Bob'
@domain='gmail.com'
email + 'bobmail'
@doc='description'
may be used to document value
@lint='language'
may be used for code text
to help linters analyze the code (if the linter support)
Comments
may be used as a note in the document
Comments
won't be parsed
Comments
are written as # some comment
Comments
are written per-line
Example:
# Hello
# Im a comment
# And i won't be parsed
name = 'Andy'
has-email = yes
# Im also a comment
# And i also won't be parsed
This pairs:
name = 'Andy'
has-email = yes
# Andy email
email = '[email protected]'
May be written in one-line as:
name = 'Andy' has-email = yes email = '[email protected]'
Don't write comments when writing in one-line
# email won't be parsed
name = 'Andy' has-email = yes # Andy email email = '[email protected]'
One-line document isn't easily readable so it's not recommended
These are special characters in CLPL
Special Character | Description |
---|---|
(space) | Reserved |
(newline) | Not parsed |
# | Comment |
@ | Annotation |
= | Assign Value |
' | Single Quote Text |
" | Double Quote Text |
[ | List Opening |
] | List Closing |
+ | Add List Value |
( | Pairs Opening |
) | Pairs Closing |
> | Modify-Pairs Opening |
< | Modify-Pairs Closing |
_ | Number Separator |
Keys can't have a newline
Keys may still use special characters except comments, annotations, or spaces
Keys may use '<key>' if it contains comments, annotations or spaces
Example:
'@name #short' = 'Andrew'
'@name #long' = 'Andrew Poppy Lawrence'
name-(without-family) = 'Andrew Poppy'
Here are some additional simple rules of CLPL:
- Value on the same line
- Pairs are constant
- Spcae sensitive
- Auto assign
- Value annotation
- Modify annotation
- No recursive annotation
✅ Valid
name = 'Bob'
❌ Invalid
name =
'Bob'
❌ Invalid
name
= 'Bob'
✅ Valid
names = [
'Bob'
'Joe'
]
profile = (
name = 'Bob'
has-phone = yes
phone = '+1 (421) 555-3511'
)
❌ Invalid
names =
[
'Bob'
'Joe'
]
profile =
(
name = 'Bob'
has-phone = yes
phone = '+1 (421) 555-3511'
)
Pair's cannot be reassigned once assigned
name = 'Bob'
# Error
name = 'Joe'
email = (
id = 'joemamamail'
domain = 'gmail.com'
)
email >
inactive = yes
# Error
domain = 'ymail.com'
<
CLPL are space-senstive
✅ Valid
name = 'Bob'
❌ Invalid
name='Bob'
✅ Weirdly Valid
a=b = 'c'
❌ Invalid
a=b='c'
Adding list value will assign the pair as list if it haven't
# Unnecessary assign
list = []
list + 'value'
# Doesn't need assign because it automatically assigned
list + 'value'
Same with modifying pairs
# Unnecessary assign
pairs = ()
pairs >
key = 'value'
<
# Doesn't need assign because it automatically assigned
pairs >
key = 'value'
<
All annotations are applied to the value (which are the pair)
@doc='Document the value'
key = 'value'
It's obvious it will also applied to the value when adding value to a list
@doc='Document the value'
list + 'value'
So it'll need to manually assign the list if want to apply anotation to the list
@doc='Document the list'
list = []
@doc='Document the value'
list + 'value'
Applying anotation to modify-pairs will still apply to the pairs
@doc='Document the pairs'
pairs >
@doc('Document the value')
key = 'value'
<
If applying annotation to modfy-pairs then it will replace the previous applied annotation
# Will get 'Note 1' as the 'note1' annotation
@note1='Note 1'
pairs >
key = 'value'
<
# Will get 'Note 1' as the 'note1' annotation
# Will get 'Note 2' as the 'note2' annotation
@note1='Note 1'
pairs = ()
@note2='Note 2'
pairs >
key = 'value'
<
# Will get 'Note 1' as the 'note1' annotation
# Will get 'Note 2' as the 'note2' annotation
@note1='Note 1'
@note2='Note 2'
pairs = ()
pairs >
key = 'value'
<
# Will get 'Note 1' as the 'note1' annotation
# Will get 'Modified Note 2' as the 'note2' annotation
@note1='Note 1'
@note2='Note 2'
pairs = ()
@note2='Modified Note 2'
pairs >
key = 'value'
<
You can't have recursive annotation
@doc=(
test = "I'll be fine"
)
key = 'value'
@doc=(
# Error here
@doc='hmm'
test = "I don't feel so good"
)
key = 'value'