Since the newline character is excluded from the graphic characters, a bare string is terminated at the first unescaped newline.
Since the newline character is excluded from the graphic characters, a bare string is terminated at the first unescaped newline. Any unescaped terminal character (such as the semicolon) will terminate a bare string. Bare strings are so named because they are *not* wrapped in quotes. These are bare strings:
# Types
Moon defines the following types:
- integers: right now this is an int based on Go semantics; it's a 32 bit int
on 32 bit CPUs, and a 64 bit int on 64 bit CPUs. These are some integers:
```
```
1
it was the best of times, it was the worst of times
2
I'm a bare string with a quote in me!
-1
But I have to escape \[ these brackets \]
-12348
0
+0
```
```
The following is a sequence of three bare strings:
- floats: they're all float64. These are some floats:
```
```
1.0
one; two; three
1.2
-9.3
3.14
1e9
```
```
- complex numbers: they're complex128 values in Go. These are some complex numbers:
##### Quoted Strings
```
A string may be enclosed in quotes. Either single quotes or double quotes may be used.
1+2i
-9+4i
```
- strings: they're strings. They're not explicitly required to be composed of
UTF-8 runes but I haven't really been testing binary data, so for the moment,
all bets are off here. They're quoted, but maybe I'll go back on that.
These are strings:
Using a single quote inside of a single-quoted string or a double-quote inside of a double-quoted string requires escaping the enclosed quote with a backslash. Quoted strings may contain newlines. These are quoted strings:
```
```
this is a bare string
"I am a great quoted string"
"this is a quoted string"
'so am I!'
'this is also a quoted string'
"I have some \"escped\" quotes inside of me"
inside of a bare string, "quotes" don't need to be escaped
but semicolons \;, colons \:, parens \( and \), brackets \[ and \] and braces \{ \} need to be escaped.
```
```
You can use single or double quotes. Escape quotes with a backslash. Quoted
# Integers
strings may contain newlines and special characters.
The following characters are special characters: `:`, `;`, `[`, `]`, `#`,
Integers are any whole number that can fit into a 32 or 64 bit integer value (depending on architecture). On 32 bit machines, an Integer is defined as int32, and on 64 bit machines, an Integer is defined as int64. Integers may be represented using either decimal, octal, or hexadecimal notation.
`{`, and `}`. The colon is used to separate a key from a value. The
semicolon is used to terminate a bare string. A newline will also terminate
a bare string. A close bracket must be a special string in order to support
a bare string being the last element of a list, without requiring that you
add a semicolon after it. An open bracket doesn't need to be a special
character, but I made it a special character to be symetrical with the close
bracket. The same logic applies for braces.
- objects: or maybe you call them hashes, objects, or associative arrays. Moon
##### Decimal Integers
calls them objects, but you'd never know it because it's actually the
`map[string]interface{}` type in Go, which is effectively the same thing.
Keys are bare strings, but object keys may not contain spaces.
These are some objects:
Decimal integers are represented by a run of digit characters, optionally preceded by a sign.
```
![Integer Diagram](grammar/diagram/Integer.png)
# key-value pairs are delimited by spaces; no commas are required
{name: "jordan" age: 28}
{
##### Octal Integers
one: 1
two: two is also a number
pi: 3.14
}
# you may use a bare string as a value, but a semicolon is required to
Octal integers are written with a preceding `0` character, followed by 1 or more characters in the range `[0-7]`.
# terminate the bare string
{name: jordan; age: 28}
```
- lists: they're `[]interface{}` values. They're not typed, and they can be
![Octal Diagram](grammar/diagram/Octal.png)
heterogenous. Values are separated by spaces. I might put commas back in,
that's kinda up in the air right now. These are some lists:
```
##### Hexadecimal Integers
[1 2 3]
[
one
2
3.14
]
# this is a list of three elements
Hex integers are written with a preceding `0x` or `0X`, followed by one or more hex characters.
[moe; larry; curly]
# this is a list of one element
![Hex Diagram](grammar/diagram/Hex.png)
[moe larry curl]
```
- variables: a variable is indicated with a `@` character. A variable may
# Floats
refer to any key that has already been defined in the current moon document.
Here is an example of how you would use a variable:
```
Floating point numbers are represented using one or more decimal points.
original_value: this is the original value, which is a string
duplicate_value: @original_value
```
If the name of a key begins with an `@` character, it is a private key. A
![Float Diagram](grammar/diagram/Float.png)
private key may be referenced in the rest of the moon document, but it is not
available anywhere outside of the moon document parser. This is useful for
the composition of larger, nested values, without polluting the document's
root namespace. Here is an example of a private key:
```
Additionally, any number written in [E Notation](http://en.wikipedia.org/wiki/Scientific_notation#E_notation) is treated as a float.
@my_private_key: a great value
my_public_key: @my_private_key
```
This isn't particularly useful for simple values, but consider the following:
# Complex numbers
```
I'm pretty sure this diagram is wrong.
@prod: {
label: production
hostname: prod.example.com
port: 9000
user: prod-user
}
@dev: {
![Complex Diagram](grammar/diagram/Complex.png)
label: development
hostname: dev.example.com
port: 9200
user: dev-user
}
servers: [@prod @dev]
# Lists
```
![List Diagram](grammar/diagram/List.png)
# Objects
![Object Diagram](grammar/diagram/Object.png)
# Variables
The only key in the root namespace of the document is `servers`; the
![Variable Diagram](grammar/diagram/Variable.png)
individual server configs are considered only a part of the document. Since
we know that these values are private to the document itself, we know we are
free to modify them as we see fit, without affecting how the host program