<commit_before>^title Syntax

Wren's syntax is designed to be familiar to people coming from C-like languages while being as simple and expressive as possible within that framework.

## Comments

Line comments start with `//` and end at the end of the line:

    :::wren
    // This is a comment.

Block comments start with `/*` and end with `*/`. They can span multiple lines or be within a single one. Unlike C, block comments can nest in Wren:

    :::wren
    /* This is /* a nested */ comment. */

## Literals

Wren currently supports a few atomic types: booleans, numbers, strings, and the null type. Numbers are double-precision floating point values, and strings are text. Wren doesn't support a lot of fancy formats for them yet, just the basic:

    :::wren
    0
    1234
    -432.1
    "a string"
    "another string"
    "supported escapes: \" \n \\"

Wren also has a couple of special values:

* `null` indicates the absence of a value.
* `this` inside a method refers to the method's receiver.
* `true` and `false` are boolean values.

## Variables

Variables are named references to values. Naming rules mostly follow C. They start with a letter and can contain letters, digits, and underscores (`_`). Some examples:

    :::wren
    foo
    Bar
    bestFriends4eva
    under_score

Variables can be declared using `var`:

    :::wren
    var pie = "pumpkin"

**TODO: Scoping**

## Method calls

Wren is object-oriented, so most code consists of method calls. They look like this:

    :::wren
    io.write("hello")
    items.add("another")
    items.insert(1, "value")

You have a *receiver* on the left, followed by a `.`, then a name and an argument list in parentheses. Semantically, a method call works like this:
<commit_msg>Fill in some more basic syntax docs.<commit_after>^title Syntax

Wren's syntax is designed to be familiar to people coming from C-like languages while being as simple and expressive as possible within that framework.

Scripts are stored in plain text files with a `.wren` file extension. Wren does
not compile ahead of time: programs are run directly from source, from top to
bottom like a typical scripting language. (Internally, programs are compiled to
bytecode for efficiency, but that's an implementation detail).

## Comments

Line comments start with `//` and end at the end of the line:

    :::wren
    // This is a comment.

Block comments start with `/*` and end with `*/`. They can span multiple lines
or be within a single one. Unlike C, block comments can nest in Wren:

    :::wren
    /* This is /* a nested */ comment. */

## Reserved Words

Some people like to see all of the reserved words in a programming language in
one lump. If you're one of those folks, here you go:

    :::wren
    class else false fn for if is null
    return static this true var while

## Newlines

Like many scripting languages, newlines are significant in Wren and are used to
separate statements. You can keep your semicolons safely tucked away.

    :::wren
    // Two statements:
    io.write("hi")
    io.write("bye")

Sometimes, though, you want to wrap a single statement on multiple lines. To
make that easier, Wren has a very simple rule. It will ignore a newline
following any token that can't end a statement. Specifically, that means any of
these:

    :::wren
    ( [ { . , * / % + - | || & && ! ~ = < > <= >= == !=
    class else if is static var while

Everywhere else, a newline is treated just like a `;`.

## Names

Identifiers are similar to other programming languages. They start with a letter or underscore and may contain letters, digits, and underscores. Case is sensitive.

    :::wren
    hi
    camelCase
    PascalCase
    _under_score
    abc123
    ALL_CAPS

Identifiers that start with underscore (`_`) are special in Wren. They are used to indicate fields and private members of classes.

## Method calls

Wren is object-oriented, so most code consists of method calls. They look like this:

    :::wren
    io.write("hello")
    items.add("another")
    items.insert(1, "value")

You have a *receiver* on the left, followed by a `.`, then a name and an argument list in parentheses. Semantically, a method call works like this:

{'fraction_non_alphanumeric': 0.08061831153388822, 'fraction_numerical': 0.0035671819262782403, 'mean_word_length': 3.278738555442523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4519274', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1150, 'n_words': 604}