~cricket/ckt

529cb1b60689e94ef994357f5010b931d4909ce9 — c piapiac 3 years ago
commit 0: initial revision (0.0.0)
3 files changed, 171 insertions(+), 0 deletions(-)

A LICENSE
A README
A SPEC
A  => LICENSE +9 -0
@@ 1,9 @@
copyright (c) 2021 <_c@piapiac.org>

permission is hereby granted to modify, distribute, and/or use this software 
in any way you damn well please as long as this entire copyright notice, 
along with the disclaimer below, is kept intact

as far as the law allows, this software comes as is, without any warranty 
or condition, and no contributor will be liable to anyone for any damages 
related to this software or license, under any kind of legal claim

A  => README +27 -0
@@ 1,27 @@
 _|_|_
(_|\|_

ABOUT
    ckt is a small, readable data format, specifically for notating tables
    it's designed to be stupid simple and easy to implement
    it easily parses into a hashmap (or dictionary, or whatever you call them)

    this repository contains only the (majorly incomplete) specification (found in SPEC)

TOOLS
    IMPLEMENTATIONS
        https://git.sr.ht/~cricket/zckt - zig ckt parser
    
    SYNTAX HIGHLIGHTING
        https://git.sr.ht/~cricket/ckt-kak - ckt syntax highlighting for kakoune

LICENSE
    ckt is licensed under the CP/PL license
    
    you can use, modify, or do whatever you please with this source, given that
    the copyright notice and warranty disclaimer are kept intact.

    read the LICENSE file for more information

AUTHORS
    do `git shortlog -sne` to show a list of all contributors

A  => SPEC +135 -0
@@ 1,135 @@
# A TOTALLY INCOMPLETE SPECIFICATION OF CRICKET TABLE NOTATION
# version 0.0.0

# DEFINITIONS:
newline = \n (0x0A)
whitespace = [ space (0x20), \t (0x09), \v (0x0B), \f (0x0C), \r (0x0D) ]
escape sequences = [
    \n = newline (0x0A)
    \v = vertical tab (0x0B)
    \f = formfeed line break (0x0C)
    \r = carriage return (0x0D)
    \t = tab (0x09)
    \" = double quote (0x22)
    \' = single quote (0x27)
    \\ = backslash (0x5C)
    \xNN = hexadecimal 8-bit value
    \uNNNN = hexadecimal unicode code point (UTF-8 encoded) (4 digits)
    \UNNNNNNNN = hexadecimal unicode code point (UTF-8 encoded) (8 digits)
]

# COMMENTS
# The hash symbol (#) starts a comment, and the comment goes all the way to the end of a line.
# They can be at the start of a line, or anywhere in the line.

# Every key is a string, and every value is either a string or a table.

# TABLES
# Tables are surrounded by [ ]
# The top level is also a table!

# Key-Value pairs are 'record style initializations':
record style initialization = this is the record style initialization
initialization with table = [ key = value ]

# Surrounding whitespace is trimmed; so this is equal
"initialization with table" = [ "key" = "value" ]

# Duplicate keys are overwritten!
x = 13
x = 16
# x now equals 16

# Unspecified keys in record-style initializations are invalid;
# = value
# However, empty keys are.
"" = value

# Bare values are 'list style initializations':
value1, value2
this has a list style table = [value 1, value 2]

# Ckt makes no ditinction between tables and lists.
# The keys of list style initialization is the previous list style key + 1, 
# starting at 0 and counting up in decimal.
equivelant to list style table = [
    0 = value 1,
    1 = value 2
]

# You can even mix and match record style and list style initializations.
polyline = [
    color = blue; thickness = 2; npionts = 4
    [ x = 0;   y = 0 ]
    [ x = -10; y = 0 ]
    [ x = -10; y = 1 ]
    [ x = 0;   y = 1 ]
]

# In a table, newliens, commas, or semicolons seperate items, and they are mostly interchangable
seperated = [
    seperated, by, commas; and; by; semicolons
    and
    by
    newlines
]

# With only one difference:
# The parser should go through newlines and whitespace until it finds a non-neline, non-whitespace character.
# If the character is '=' then its a k/v pair; EG
this is valid
= value

# This is fine. This should be interpreted the same as "this is valid" = "value"
# However;
this is invalid;
= value
# This is not valid. It will interpret "this is invalid" and "= value" as two items of a table using list initialization syntax,
# and will error, as '=' is not allowed in unquoted strings.

# Same goes here:
this is also valid= 
value

this is not also valid =;
value

# And of course:
this too is valid
=
value

# STRINGS
# Strings can be unquoted, quoted, or multiline

# Unquoted strings are not escaped (what you see is what you get)
this is a bare unquoted string
this string includes \n which is not interpreted as a newline

# Quoted strings are surrounded by " or ', and are escaped (see escape sequences under DEFINITIONS)
'this is a quoted string'
"this is also a quoted string"

# This are useful if you need a string that includes any of [ ] = , ; | # " '
tag = "#Epic"

# Or if you need escaped characters
multiple lines quoted = "this string\nspans\nmultiple lines"

# Multiline strings start with a | on every line, and are mostly not escaped.
multiline string =
    |This string spans multiple lines.
    |Isn't it so cool?

# Aside from escape hatches. A \ before a newline in a multiline string will cause the next line to be on the same.
# A \ before the EOF should be interpreted as nothing.
singleline multiline string =
    |This string only spans \
    |a single line.

singleine unquoted string = This string only spans a single line.

# Escape hatches themselves can be escaped.
escaped escape hatches =
    |This line ends in a single backslash. \\
    |This line ends with two! \\\