aboutsummaryrefslogtreecommitdiffstats
path: root/docs/guide/syntax.md
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-17 15:41:56 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:24:49 +0000
commit406da94f13f47a9c7aef6b9c11cfe057772630cf (patch)
treedd98e12eddd421e2883c90239cb10225bb75b07e /docs/guide/syntax.md
parentbuiltin/trae: print literals literally (diff)
downloadalive-406da94f13f47a9c7aef6b9c11cfe057772630cf.tar.gz
alive-406da94f13f47a9c7aef6b9c11cfe057772630cf.zip
split guide into multiple pages
Diffstat (limited to 'docs/guide/syntax.md')
-rw-r--r--docs/guide/syntax.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/guide/syntax.md b/docs/guide/syntax.md
new file mode 100644
index 0000000..93f1c61
--- /dev/null
+++ b/docs/guide/syntax.md
@@ -0,0 +1,43 @@
+`alv`'s syntax is very similar to Lisp. Expressions take the form of
+parenthesized lists like `(head a b c...)`, where the first element of the list
+(`head`) is the name of an operator or function, which defines what the
+expression as a whole will do, while the other elements are parameters whose
+meaning depends on the `head`. Let's start with a simple operator, [print][]:
+[print][] is used simply to print messages to the copilot console.
+
+## expressions
+Elements of an expression have to be separated by whitespace, but any type of
+and amount of whitespace is valid: feel free to use spaces, tabs, and newlines
+to format code to your liking. The following are all equal and valid examples:
+
+ (print "hello world")
+
+ (+ 1
+ 2
+ 3)
+
+ (print
+ "hello world")
+
+ ( print "hello world" )
+
+It is however recommended to follow the [clojure style guide][clojure-style] as
+much as it does apply to alv. All further examples in this guide will respect
+this guideline, so you might just pick it up simply by following this guide.
+
+## comments
+To annotate your code, you can use comments. In `alv`, comments begin with
+`#(` and end on a matching `)`. This way you can comment out a complete
+expression simply by adding a `#` character in front.
+
+ #(this is a comment)
+
+ #(this is a long,
+ multi-line comment,
+ (and it also has nested parentheses).
+ It ends after this sentence.)
+
+You can put comments anywhere in your program where whitespace is allowed and
+it will simply be ignored by `alv`.
+
+[clojure-style]: https://github.com/bbatsov/clojure-style-guide