Skip to content

Commit 0c52467

Browse files
author
Kevan Stannard
committed
Add basic operators to the syntax widget
1 parent 90ee93f commit 0c52467

11 files changed

+402
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *floating point* addition.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 1.3 +. 0.5
11+
```
12+
13+
```js
14+
var result = 1.3 + 0.5;
15+
```
16+
17+
</CodeTab>
18+
19+
For adding *integers* see the `+` operator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *floating point* division.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 3.0 /. 2.5
11+
```
12+
13+
```js
14+
var result = 3.0 / 2.5;
15+
```
16+
17+
</CodeTab>
18+
19+
For dividing *integers* see the `/` operator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *floating point* multiplication.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 1.5 *. 2.3
11+
```
12+
13+
```js
14+
var result = 1.5 * 2.3;
15+
```
16+
17+
</CodeTab>
18+
19+
For multiplying *integers* see the `*` operator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *floating point* subtraction.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 3.0 -. 2.5
11+
```
12+
13+
```js
14+
var result = 3.0 - 2.5;
15+
```
16+
17+
</CodeTab>
18+
19+
For subtracting *integers* see the `-` operator.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *integers* addition.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 1 + 2
11+
```
12+
13+
```js
14+
val result = 3;
15+
```
16+
17+
</CodeTab>
18+
19+
For adding *floats* see the `+.` operator.
20+
21+
For contatenating *strings* see the `++` operator.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *integer* division, with the result truncated to an integer value.
6+
7+
If the second argument is *zero* then a `Division_by_zero` exception is thrown. Refer to the [Exception](/docs/manual/latest/exception) section for handling exceptions.
8+
9+
<CodeTab labels={["ReScript", "JS Output"]}>
10+
11+
```res
12+
let result = 3 / 2
13+
```
14+
15+
```js
16+
var result = 1;
17+
```
18+
19+
</CodeTab>
20+
21+
For dividing *floats* see the `/.` operator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *integer* multiplication.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 2 * 3
11+
```
12+
13+
```js
14+
var result = 6;
15+
```
16+
17+
</CodeTab>
18+
19+
For multiplying *floats* see the `*.` operator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator performs *integer* subtraction.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let result = 3 - 2
11+
```
12+
13+
```js
14+
var result = 1;
15+
```
16+
17+
</CodeTab>
18+
19+
For subtracting *floats* see the `-.` operator.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
test: "foo"
3+
---
4+
5+
This operator concatenates two *strings* together.
6+
7+
<CodeTab labels={["ReScript", "JS Output"]}>
8+
9+
```res
10+
let greetings = "Hello " ++ "world!"
11+
```
12+
13+
```js
14+
var greetings = "Hello world!";
15+
```
16+
17+
</CodeTab>
18+
19+

src/components/SyntaxLookupWidget.js

Lines changed: 128 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)