blanket-script 0.0.2

BlanketScript is a simple script language inspired by Rust that transpiles to JavaScript.
Documentation
# Data Types

## `number`

The `number` type represents numeric values including integers and floating-point values. It maps directly to JavaScript's `number` type, maintaining the same range and precision characteristics including IEEE 754 double-precision format. Numbers support underscores as visual separators between digits for improved readability and scientific notation for writing out large numbers.

### Grammar

```
NonZeroDigit ::= '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'

Digit ::= '0' | NonZeroDigit

DelimitedDigit ::= Digit | '_' Digit

WholeNumber ::= NonZeroDigit DelimitedDigit*

DecimalNumber ::= WholeNumber ('.' DelimitedDigit*)?

ScientificNotation ::= DecimalNumber ('e' | 'E') ('+' | '-')? Digit DelimitedDigit*

Number ::= DecimalNumber | ScientificNotation
```

### Examples

```rust
// Valid `number`s
let a = 42;
let b = 3.14159;
let c = 1_000_000;           // Equivalent to 1000000
let d = 3.141_592_653_589;   // Underscores in decimal portion
let e = 1e10;                // Scientific notation (10 billion)
let f = 1.5e-5;              // Scientific notation (0.000015)
let g = 0.123;

// Invalid `number`s
// let invalid1 = _123;      // Cannot start with underscore
// let invalid2 = 123_;      // Cannot end with underscore
// let invalid3 = 1__2;      // Cannot have consecutive underscores
// let invalid4 = .123;      // Must have leading digit before decimal
```

## `bigint`

The `bigint` type represents arbitrary-precision integers, allowing for integers of arbitrary size. It maps directly to JavaScript's `bigint` type. Like `number`, it support underscores as visual separators between digits for improved readability and scientific notation for writing out large numbers.

> [!NOTE]
>
> `bigint`s can use scientific notation unlike ECMAScript `bigint`s. They are parsed
> in the same way `number`s are. However, they are required to be whole numbers in
> type-checking time.

### Grammar

```
BigInt ::= (WholeNumber 'n') | (ScientificNotation 'n')
```

### Examples

```rust
// Valid `bigint`s
let a = 42n;             // Simple
let b = 1000000000n;     // Billion
let b = 1_000_000_000n;  // Billion with separators.
let d = 1e10n;           // Scientific notation
let e = 100e-2n          // Negative scientific notation
//  ^ resolves to 1 at compile time so it's safe.
let f = 1.234n           // Scientific notation with decimalsx

// Invalid `bigint`s
// let invalid1 = n;         // Cannot be empty
// let invalid2 = 123_n;     // Cannot have underscore before 'n'
// let invalid3 = _123n;     // Cannot start with underscore
// let invalid4 = 1__000n;   // Cannot have consecutive underscores
```

## `String`

### Description

The `String` type represents textual data as a sequence of UTF-8 code units delimited by `"`, single-quotes for strings aren't supported like JS. Strings are converted to UTF-16 encoding at compile time, since ECMAScript uses UTF-16 encoding for strings. Strings support interpolation using curly braces `{}` to embed expressions within the string. To include literal curly braces, they can be escaped by doubling them as `{{` and `}}`. Backslashes are used to add escape sequences including double quotes, newline, carriage return, tab, null-byte and actual backslashes. ASCII characters can be added by `\xHH` where `HH` is hexadecimal value of ASCII character, for example `"\x41"` is equal to `"A"`. Arbitrary unicode code-points can be added using `\u{XX}` syntax from U+0000 to U+D7FF and U+E000 to U+10FFFF.

### JS Mapping

Maps to JavaScript's `String` type, with interpolation compiled to template literals.

### Grammar

```
HexDigit ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
    | 'a' | 'b' | 'c' | 'd' | 'e' | 'f'
    | 'A' | 'B' | 'C' | 'D' | 'E' | 'F'

UnicodeCodePoint ::=
    | '\u' '{' HexDigit{2,6} '}'
    | '\x' HexDigit HexDigit

EscapedCharacter ::=
    | '\\'
    | '\"'
    | '\n'
    | '\r'
    | '\t'
    | '\0'
    | '{{'
    | '}}'

RegularChar ::= !('"' | '\' | '{' | '}')

StringCharacter ::=
    | EscapedCharacter
    | UnicodeCodePoint
    | RegularChar

Interpolation ::= '{' Expression '}'

String ::= '"' (StringCharacter | Interpolation)* '"'
```

### Examples

```rust
// Valid Strings
let name = "Alice";
let greeting = "Hello, {name}!";               // Interpolation
let formula = "The formula is: x = {2 + 3}";   // Expression interpolation
let escaped = "Curly braces: {{ and }}";       // Escaped braces
let multiline = "This is a
multi-line string";
let unicode = "Unicode: \u00A9";               // Copyright symbol ©

// Invalid Strings
// let invalid1 = 'Single quotes not allowed';  // Must use double quotes
// let invalid2 = "Unescaped { is invalid";     // Unmatched braces
// let invalid3 = "Missing closing brace {";    // Missing closing brace
```