Skip to content

Commit bd2a478

Browse files
authored
Merge pull request #165 from kevanstannard/syntax-widget-basic-operators
Add basic operators to the syntax widget
2 parents 90ee93f + 1da0c4a commit bd2a478

11 files changed

+438
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "float-addition"
3+
keywords: ["plus", "add", "addition", "sum", "float"]
4+
name: "+."
5+
summary: "This is the `floating point addition` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *floating point* addition.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 1.3 +. 0.5
15+
```
16+
17+
```js
18+
var result = 1.3 + 0.5;
19+
```
20+
21+
</CodeTab>
22+
23+
For adding *integers* see the `+` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "float-division"
3+
keywords: ["divide", "division", "float"]
4+
name: "/."
5+
summary: "This is the `floating point division` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *floating point* division.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 3.0 /. 2.5
15+
```
16+
17+
```js
18+
var result = 3.0 / 2.5;
19+
```
20+
21+
</CodeTab>
22+
23+
For dividing *integers* see the `/` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "float-multiplication"
3+
keywords: ["multiply", "multiplication", "float"]
4+
name: "*."
5+
summary: "This is the `floating point multiplication` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *floating point* multiplication.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 1.5 *. 2.3
15+
```
16+
17+
```js
18+
var result = 1.5 * 2.3;
19+
```
20+
21+
</CodeTab>
22+
23+
For multiplying *integers* see the `*` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "float-subtraction"
3+
keywords: ["subtract", "minus", "subtraction", "float"]
4+
name: "-."
5+
summary: "This is the `floating point subtraction` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *floating point* subtraction.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 3.0 -. 2.5
15+
```
16+
17+
```js
18+
var result = 3.0 - 2.5;
19+
```
20+
21+
</CodeTab>
22+
23+
For subtracting *integers* see the `-` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
id: "integer-addition"
3+
keywords: ["plus", "add", "addition", "sum", "int", "integer"]
4+
name: "+"
5+
summary: "This is the `integer addition` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *integers* addition.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 1 + 2
15+
```
16+
17+
```js
18+
val result = 3;
19+
```
20+
21+
</CodeTab>
22+
23+
For adding *floats* see the `+.` operator.
24+
25+
For contatenating *strings* see the `++` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
id: "integer-division"
3+
keywords: ["divide", "division", "int", "integer"]
4+
name: "/"
5+
summary: "This is the `integer division` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *integer* division, with the result truncated to an integer value.
10+
11+
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.
12+
13+
<CodeTab labels={["ReScript", "JS Output"]}>
14+
15+
```res
16+
let result = 3 / 2
17+
```
18+
19+
```js
20+
var result = 1;
21+
```
22+
23+
</CodeTab>
24+
25+
For dividing *floats* see the `/.` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "integer-multiplication"
3+
keywords: ["multiply", "multiplication", "int", "integer"]
4+
name: "*"
5+
summary: "This is the `integer multiplication` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *integer* multiplication.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 2 * 3
15+
```
16+
17+
```js
18+
var result = 6;
19+
```
20+
21+
</CodeTab>
22+
23+
For multiplying *floats* see the `*.` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "integer-subtraction"
3+
keywords: ["subtract", "minus", "subtraction", "int", "integer"]
4+
name: "-"
5+
summary: "This is the `integer subtraction` operator."
6+
category: "operators"
7+
---
8+
9+
This operator performs *integer* subtraction.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let result = 3 - 2
15+
```
16+
17+
```js
18+
var result = 1;
19+
```
20+
21+
</CodeTab>
22+
23+
For subtracting *floats* see the `-.` operator.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
id: "string-concatenation"
3+
keywords: ["concat", "concatenation", "add", "string"]
4+
name: "++"
5+
summary: "This is the `string concatenation` operator."
6+
category: "operators"
7+
---
8+
9+
This operator concatenates two *strings* together.
10+
11+
<CodeTab labels={["ReScript", "JS Output"]}>
12+
13+
```res
14+
let greetings = "Hello " ++ "world!"
15+
```
16+
17+
```js
18+
var greetings = "Hello world!";
19+
```
20+
21+
</CodeTab>
22+
23+

src/components/SyntaxLookupWidget.js

+128
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)