From 17e070553b1e5b29b638b694b456de8e55553a23 Mon Sep 17 00:00:00 2001 From: mediocregopher Date: Mon, 27 May 2013 00:56:04 -0400 Subject: [PATCH] added readme, and space escaped character --- README.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ parse.go | 1 + 2 files changed, 98 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..8252341 --- /dev/null +++ b/README.md @@ -0,0 +1,97 @@ +# Ginger + +A scripted lisp language with simple syntax, immutable data structures, concurrency built-in, and +minimal time between starting the runtime and actual execution. + +# Syntax + +Ginger is a lisp language, so knowing the syntax is as simple as knowing the data structures. + +## Strings + +Strings are declared two different ways. The standard way, with double quotes: +``` +"this is a string\n <- that was a newline, \t \r \0 \" \\ also work +literal whitespace characters are properly parsed as well +\s is a space" +``` + +The second way only works if your string contains exclusively the following characters: +`a-z A-Z 0-9 _ - ! ?` (spaces added for readability) +``` +neat +this_works +so-does-this! +what-about-this?_YUP! +``` + +## Integers + +Integers are defined the standard way, a bunch of numbers with an optional negative. The only +interesting thing is that commas inside the number are ignored, so you can make your literals pretty: +``` +0 +1 +-2 +4,000,000 +``` + +## Floats + +Pretty much the same as integers, but with a period thrown in there. If there isn't a period, it's not +a float: +``` +0.0 +-1.5 +-1,003.004,333,203 +``` + +## Bytes + +Singular unsigned bytes, are also supported. There are two ways to declare them. With a trailing `b`: +``` +0b +10b +255b +``` + +and with a `'` followed by a character (or escaped character): +``` +'c +'h +'\n +'\\ +'' +``` + +## Vectors + +A vector is a sequence of elements wrapped in `[ ... ]` (no commas): +``` +[ a b 0 1 2 + [embedded also works] +] +``` + +## Lists + +A list is a sequence of elements wrapped in `( ... )` (no commas): +``` +( a b 0 1 2 + [embedded also works] + (and mixed types) +) +``` + +## Maps + +A map is a sequence of elements wrapped in `{ ... }`. There must be an even number of elements, and +there is no delimeter between the keys and values. Keys can be any non-sequence variable, values can +be anything at all: +``` +{ a 1 + b 2 + c [1 2 3] + d (four five six) + e { 7 seven } } +``` diff --git a/parse.go b/parse.go index 1a21947..11b023d 100644 --- a/parse.go +++ b/parse.go @@ -64,6 +64,7 @@ var SpecialCharsMap = map[byte]byte{ 'n' : '\n', 'r' : '\r', 't' : '\t', + 's' : ' ', '0' : 0, }