-
Notifications
You must be signed in to change notification settings - Fork 3
5 The Language
CSpydr is free-from, meaning that spaces and comments are ignored, except in strings, in characters and as delimiters between tokens. Spaces are recognized as whitespaces, carriage returns and tabs. Only ASCII characters are accepted.
Identifiers consist of a series of alphanumeric characters or underscores, not starting with a digit. Next to that, CSpydr is case-sensitive. meaning that myid and myID are two different identifiers. When compiled with the C backend identifiers may not start with __csp_
.
CSpydr has a series of keywords, which cannot be used as identifiers
Keywords:
true false nil let fn
loop while for if else
ret match type struct union
enum import const extern macro
namespace sizeof typeof alignof break
continue noop len asm using
with
Symbols:
++ += + -- -= - *= *
%= % /= / &= && & ^
^= <<= >>= << >> || |= |>
| == => = != ! >= <=
<- < > ( ) { } [
] ~ , ; _ :: ... ²
³ $ `
Strings & Characters:
String literals are delimited by double quotes ("
) and can contain any amount of any character except non-escaped double quotes.
Character literals are delimited by single quotes ('
) and can only contain one single character, or an escape sequence. These escape sequences include the following:
Literal characters | Interpreted character |
---|---|
\a | Bell (alert) |
\b | Backspace |
\f | Form Feed |
\n | Newline |
\r | Carriage return |
\t | Horizontal Tab |
\v | Vertical Tab |
' | Single Quote |
" | Double Quote |
\ | Backslash |
\0 | Null character |
Numbers:
An integer constant can be written as decimal, hexadecimal, binary or octal. Floating-point constants can only be written in decimal and must include a radix point. All number literals can contain as many underscores _
as you like for better visual parsing. Examples of valid numerical constants are the following:
99 1 1_000_000
0xff 0xabcdef 0x3d
0o77 0o7234 0o0
0b11 0b10010 0b11011
1.2 3.1415 1_234.567
Comments:
Comments can be either single-line or blocks. Single-line comments are denoted by a hashtag #
and include the rest of the line, while block comments are denoted by #[
and go on until ]#
.
2.1 - Compatibility
2.2 - Obtaining CSpydr
2.3 - Dependencies
2.4 - Building
2.5 - Installation
2.6 - Usage
4.1 - Types and Values
4.2 - Type Modifiers
4.3 - Truthiness
4.4 - Naming Conventions
5.1 - Lexical Conventions
5.2 - Variables, Members and Arguments
5.3 - Statements
5.3.1 - Blocks
5.3.2 - Loops
5.3.3 - Control Flow
5.3.4 - Expression Statements
5.3.5 - Variable Declarations
5.4 - Expressions
5.4.1 - Literals
5.4.2 - Operator Precedence
5.4.3 - Binary Operators
5.4.4 - Unary Operators
5.4.5 - Postfix Operators