Skip to content

Commit

Permalink
Update SPEC.md
Browse files Browse the repository at this point in the history
  • Loading branch information
watcol committed Oct 25, 2021
1 parent e443787 commit d08aa93
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ This book is the specification for the Walnut configuration language that
speifies syntax and semantics. Parser and interpreter implementations must
follow this specification.

Note that I used [TOML v1.0.0](https://toml.io/en/v1.0.0) as a sample to write
this specification. I'm grateful to the authors and contributors.

## The terms
- "Whitespace" means tab (`U+0009`) or space (`U+0020`).
- "Newline" means line feed (`U+000A`) or carriage return (`U+000D`).
- "Parenthesis" means left and right of round brackets (`()`), curly brackets
(`{}`), or square brackts (`[]`).

## Table of Contents
- File Format
Expand Down Expand Up @@ -46,10 +45,23 @@ this specification. I'm grateful to the authors and contributors.
- The appropriate MIME type for Walnut files is `application/walnut`.

## Line
Line is the string between two [newline](#the-term) characters (or the
beginning of a file), expcept newlines escaped by `\`, newlines surrounded by
[parentheses](#the-terms) or newlines in [strings](#string). The former two
cases are treated as a [whitespace](#the-term), but in the latter case, the
behavior is decided by the kind of string. See also:
[Expression/String](#string)

[Whitespaces](#the-terms) in the beginning or the end of a line and a
[comment](#comment) in the middle, or the end of a line will be ignored (= is
equivalent to empty text). Therefore, a comment in the middle of a line will
be interpreted as a whitespace, and one in the end of a line will be ignored.

### Comment
Comment is an string starts with hash symbol (`#`, `U+0023`) outside a string,
and ends with line feed (`U+000A`) or carriage return (`U+000D`). Line feeds
and carriage returns are not permitted in comments. Comments are allowed in the end of [lines](#line) (before newline character).
Comment is a text starts with hash symbol (`#`, `U+0023`) outside a
[string](#string), (inside [parentheses](#the-term) are allowed) and
continues until the appearance of a [newline](#the-term) character (not
included). Newline characters are not permitted in comments.

```
# This is an comment
Expand Down

0 comments on commit d08aa93

Please sign in to comment.