1. Lexical structure

1.1 Source files

1.2 Lines and indentation

Taught in 1. Hello

1.3 Comments

Taught in 1. Hello

# followed by a space, or # at the end of a line, starts a comment that runs to the end of the line. A comment may stand on its own line or follow a statement after one space. Everything after the first space is the comment's text, kept verbatim; a bare # is an empty comment.

1.4 Words

Taught in 4. First node

word   = letter { letter | digit } ;
member = word "." word { "." word } ;   (* one token, no spaces around "." *)

1.5 Numbers and durations

Taught in 2. Values, 3. Time

number   = [ "-" ] digits [ "." digits ] ;
duration = number ( "ms" | "s" ) ;      (* no space between number and unit *)

1.6 Text

Taught in 1. Hello

text = '"' { char | escape } '"' ;
escape = '\"' | '\\' | '\n' ;

Double quotes only. Text is immutable. Text holds no control characters (U+0000 to U+001F, U+007F, tabs included); write \n for a line break. An unknown escape or an unterminated text is a syntax error.

1.7 Colors

Taught in 12. Looks

color = "#" hex hex hex hex hex hex ;

Color literals are allowed only as the argument of result in a phrase with no holes, which names the color (see spec/09). Everywhere else colors are named: theme.Accent.

1.8 Punctuation

Token Only use
[ ] holes: in define patterns (receivers included) and in when (receivers and typed event bindings)
: inside a hole, between name and type
( ) a nested sentence
{ } a list literal, or the empty list/map {}
, between list items, between settings after message … with, and between the two names after each
. members: net.Send, n.Known, Vote.term; also inside numbers and import paths

1.9 Paths

Import paths appear only after use and are lexed as a single token:

path    = segment { "/" segment } [ "@" version ] ;
segment = ( letter | digit ) { letter | digit | "." | "-" } ;
version = "v" digits "." digits "." digits ;

std/net, github.com/synodlang/examples/raft, github.com/someone/raft@v1.2.0.

1.10 Reserved words

The following words are language words and cannot be used as names:

use as define native main start has set to when after deliver emit
if else each in result always draw for message with of item list map
is not at least most less more than and or plus minus times divided by
true false

(at least, at most, less than, more than, divided by, is in, is not, is not in are multi-word operators built from these words.)

main and start appear only in the entry definitions define main and define [n: Node] start. list and map appear only in types (list of node, map of text to number).