Skip to content

Commit c4d9b74

Browse files
committed
feat(reference): Lexical Structure—Whitespace
1 parent bba056b commit c4d9b74

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

docs_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ docs_groups:
8181
- stdlib/bigint
8282
Language Reference:
8383
- reference/introduction
84-
- reference/lexical_structure
85-
# - reference/lexical_structure/whitespace
84+
- reference/lexical_structure:
85+
- reference/lexical_structure/whitespace
8686
# - reference/lexical_structure/comments
8787
# - reference/lexical_structure/keywords
8888
# - reference/lexical_structure/identifiers
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
title: Whitespace
3+
---
4+
5+
Spaces (`' '`), tabs (`'\t'`), carriage returns (`'\r'`), and line feeds (`'\n'`) are all considered whitespace.
6+
7+
## Spaces & tabs
8+
9+
Spaces and tabs serve no purpose other than separating tokens and otherwise have no meaning in a Grain program. They can be used interchangably and come in any amount.
10+
11+
## Carriage returns & line feeds
12+
13+
Lines in a program are delimited by a single line feed, `'\n'` (as commonly found on Unix-like systems), or by a carriage return followed by a line feed, `'\r\n'` (as commonly found on Windows systems). The lexer will accept both line ending types appearing in the same file, though mixing line endings is generally not recommended.
14+
15+
Line breaks have significant meaning in Grain (e.g. ending a statement), so a `NEWLINE` token is produced when the lexer encounters a line ending.

0 commit comments

Comments
 (0)