Skip to content

Commit

Permalink
Update array and type instantiation
Browse files Browse the repository at this point in the history
  • Loading branch information
patriksvensson committed May 26, 2024
1 parent ce6d69e commit fe1875c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
10 changes: 5 additions & 5 deletions docs/language/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@ sidebar_position: 60
In the provided code snippet, we can see how arrays work:

```mew
let foo = string[] { "A", "B", "C" };
let foo = new string[] { "A", "B", "C" };
let bar = i32[4];
bar[0] = 0;
bar[1] = 1;
bar[2] = 2;
bar[3] = 3;
let qux = i32[4] { 0, 1, 2, 3 };
let qux = new i32[4] { 0, 1, 2, 3 };
```

### Array initialization

```mew
let foo = string[] { "A", "B", "C" };
let foo = new string[] { "A", "B", "C" };
```

This line declares an array of type `string` and initializes it with three string elements "A", "B", and "C". In Mew, arrays can be initialized with values directly using the curly braces syntax.

```mew
let bar = i32[4];
let bar = new i32[4];
```

This line declares an array of type `i32`, specifying the size of the array as 4. The array is created, but it is initially empty.
Expand All @@ -49,7 +49,7 @@ Similarly, this line assigns 1 to the second element at index 1, and so on for t
### Array Initialization with Values

```mew
let qux = i32[4] { 0, 1, 2, 3 };
let qux = new i32[4] { 0, 1, 2, 3 };
```

This line declares an array of type `i32` and initializes it with four integer values: 0, 1, 2, and 3. This is another way to create and initialize an array with specific values at the time of declaration.
8 changes: 1 addition & 7 deletions docs/language/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,10 @@ sidebar_position: 70
pub static fn square(value: i32) -> i32 {
return value * value;
}
// Static function with optional label
pub static fn log(_ content: any) {
print(content);
}
```

### Calling functions

```mew
let result = square(value: 32);
log(result);
let result = square(32);
```
10 changes: 5 additions & 5 deletions docs/language/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ sidebar_position: 80

# Types

_Work in progress_

### Fields

:::note
Expand All @@ -20,7 +18,9 @@ pub type Person {

```mew
// Usage:
let person = Person(name: "Patrik");
let person = new Person {
name: "Patrik"
};
```

### Methods
Expand All @@ -37,7 +37,7 @@ pub type Clock {

```mew
// Usage:
let clock = Clock();
let clock = new Clock();
let now = clock.get_current_time();
```

Expand Down Expand Up @@ -75,5 +75,5 @@ pub type Person {

```mew
// Usage:
let person = Person::new(name: "Patrik");
let person = Person::new("Patrik");
```
2 changes: 1 addition & 1 deletion src/prism/prism-mew.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Prism.languages.mew = Prism.languages.extend('clike', {
lookbehind: true,
greedy: true
},
'keyword': /\b(?:external|union|where|namespace|match|mut|static|pub|use|type|interface|impl|field|while|loop|break|continue|else|fn|if|return|let|for|in|as|print)\b/,
'keyword': /\b(?:new|external|union|where|namespace|match|mut|static|pub|use|type|interface|impl|field|while|loop|break|continue|else|fn|if|return|let|for|in|as|print)\b/,
'boolean': /\b(?:_|false|iota|nil|true)\b/,
'number': [
// binary and octal integers
Expand Down

0 comments on commit fe1875c

Please sign in to comment.