Skip to content

SP-Lang Syntax¤

Info

SP-Lang syntax is using YAML 1.2

Comments¤

An comment is marked by a # indicator.

# This file contains no
# SP-Lang, only comments.

Numbers¤

Integer¤

canonical: 12345
positive decimal: +12345
negative decimal: -12345
octal: 0o14
hexadecimal: 0xC

Floating Point¤

fixed: 1230.15
canonical: 1.23015e+3
exponential: 12.3015e+02
negative infinity: -.inf
not a number: .nan

Strings¤

string: '012345'
string without quotes: You can specify string without any quotation as well
emoji: 😀🚀⭐

Quoted strings:

unicode: "Sosa did fine.\u263A"
control: "\b1998\t1999\t2000\n"
hex esc: "\x0d\x0a is \r\n"

single: '"Howdy!" he cried.'
quoted: ' # Not a ''comment''.'

Multiline strings:

|
   _____ _____        _                       
  / ____|  __ \      | |                      
 | (___ | |__) |_____| |     __ _ _ __   __ _ 
  \___ \|  ___/______| |    / _` | '_ \ / _` |
  ____) | |          | |___| (_| | | | | (_| |
 |_____/|_|          |______\__,_|_| |_|\__, |
                                         __/ |
                                        |___/ 

The literal style (indicated by |) preserves initial spaces.

>
  Mark McGwire's
  year was crippled
  by a knee injury.

The folded style (denoted by >) removes eventual YAML indentation.

Booleans¤

True boolean: true
False boolean: false

Expressions¤

All SP-Lang expressions (aka functions) starts with !, SP-Lang expressions are therefore YAML tags (!TAG).

Expressions can be of thee types:

  • Mapping
  • Sequence
  • Scalar

Mapping expression¤

Example:

!ENDSWITH
what: FooBar
postfix: Bar

A flow form example:

!ENDSWITH {what: FooBar, postfix: Bar}

YAML specification

See chapter 10.2. Mapping Styles

Sequence expression¤

Example:

!ADD  
- 1  
- 2  
- 3  

A flow form example:

!ADD [1, 2, 3]  

YAML specification

See chapter 10.1. Sequence Styles

Sequence expression could be defined using with argument as well:

!ADD
with: [1, 2, 3]

Tip

This is actually a mapping form of the sequence expression.

Scalar expressions¤

Example:

!ITEM EVENT potatoes

YAML specification

See chapter 9. Scalar Styles

Anchors and Aliases¤

SP-Lang leverages YAML anchors and aliases. It means that you may refer to the result of the other expression by the anchor. The anchor is a string starting with "&". The result of the expression annotated by the anchor can then be reused by the alias, which is a string starting with "*", sharing the anchor's name. One anchor can be referenced by many aliases.

Example:

!ADD
- 1
- &subcount !MUL
  - 2
  - 3
- *subcount
- *subcount

Equals to 1+(2*3)+(2*3)+(2*3) respective 19.

Structure of the SP-Lang file¤

SP-Lang uses three dashes (---) to separate expressions from document content. This also serves to signal the start of a SP-Lang. Three dots ( “...”) indicate the end of a file without starting a new one, for use in communication channels.

The file extension of SP-Lang is .yaml.

Example of the SP-Lang file:

multiplication.yaml
---
# Let's do some basic math
!MUL
- 1
- 2
- 3

Note

SP-Lang file always starts with --- line.

Info

One file can contain more expressions using YAML separator (---).