-
Notifications
You must be signed in to change notification settings - Fork 2
Literals
Anything that's not a programmatic operator (like a function, a mixin call or a variable assignment) is considered to be a literal in SCL. This includes block identifiers, declarations and declaration values. Because SCL is ultimately compiles to HCL, which in turn parses the values, literals can be, well, literally anything. That said, there are five basic types of literals, all of which are fairly intuitive. In fact, if you've seen SCL at all, you've probably identified most or all of the possible literals already.
Numbers are a series of digits, including up to one . character to indicate that it's a decimal, and an optional minus sign. Numbers are assumed to be base 10. If you prefix a number with 0x, it is treated as a hexadecimal. If it is prefixed with 0, it is treated as an octal. Numbers can be in scientific notation: "1e10".
Strings are a series of any character encapsulated by 's or "s. As per the SCL syntax rules, they must fit on a single line, but can otherwise be of any length.
Numbers and strings can be serialised in an array, which is encapsulated in square brackets, with the array entries separated by commas. All entities in an array must of the same type (either strings or numbers). Trailing commas are not accepted. Variables will interpolate into arrays.
Examples of arrays include:
[1,2,3]
["one","two","three"]
Block identifiers are the headers than encapsulate blocks. Most of the time in Sepia, they will be masked by the standard library, but you may still want to use them from time to time. Block identifiers are 'raw' strings, in as far as they are not encapsulated by any kind of quotes or other delimiters. The may be comprised of letters, numbers and underscores, but must start with a letter.
When you assign a value to something in SCL, you're making a declaration assignment. The left operand of that statement is the declaration. In this code, for example:
thing = 1
The declaration thing is being assigned the number value 1. Since SCL is a configuration language, its goal is to make declaration assignments, and they therefore form the core of everything it does.
It's important to note that a declaration must be a assigned to a number, a string or an array. The following is not valid:
thing = someThing
because someThing has no meaning to the parser, even if it was defined earlier in the scope. If you want dynamic assignments of that nature, you need to use variables.
Heredocs are multi-line strings. They must start with <<EOF at the end of a line, and end with EOF on its own line. Any text may be used in place of EOF. Heredoc values are subject to variable interpolation and they may be assigned to variables, but they are not parsed like SCL in terms of blocks and scope: they are literal, multi-line chunks of HCL. For example:
$myValue = 10
$myHeredoc = <<DOC
block "output exactly as is!" {
one = $myValue
}
DOC
thing = $myHeredoc
The above is valid SCL, and outputs the following:
thing = <<DOC
block "output exactly as is!" {
one = 10
}
DOC