Skip to content

Commit

Permalink
Merge pull request #165 from kevanstannard/syntax-widget-basic-operators
Browse files Browse the repository at this point in the history
Add basic operators to the syntax widget
  • Loading branch information
ryyppy authored Jan 4, 2021
2 parents 90ee93f + 1da0c4a commit bd2a478
Show file tree
Hide file tree
Showing 11 changed files with 438 additions and 0 deletions.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_float_addition.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "float-addition"
keywords: ["plus", "add", "addition", "sum", "float"]
name: "+."
summary: "This is the `floating point addition` operator."
category: "operators"
---

This operator performs *floating point* addition.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 1.3 +. 0.5
```

```js
var result = 1.3 + 0.5;
```

</CodeTab>

For adding *integers* see the `+` operator.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_float_division.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "float-division"
keywords: ["divide", "division", "float"]
name: "/."
summary: "This is the `floating point division` operator."
category: "operators"
---

This operator performs *floating point* division.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 3.0 /. 2.5
```

```js
var result = 3.0 / 2.5;
```

</CodeTab>

For dividing *integers* see the `/` operator.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_float_multiplication.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "float-multiplication"
keywords: ["multiply", "multiplication", "float"]
name: "*."
summary: "This is the `floating point multiplication` operator."
category: "operators"
---

This operator performs *floating point* multiplication.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 1.5 *. 2.3
```

```js
var result = 1.5 * 2.3;
```

</CodeTab>

For multiplying *integers* see the `*` operator.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_float_subtraction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "float-subtraction"
keywords: ["subtract", "minus", "subtraction", "float"]
name: "-."
summary: "This is the `floating point subtraction` operator."
category: "operators"
---

This operator performs *floating point* subtraction.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 3.0 -. 2.5
```

```js
var result = 3.0 - 2.5;
```

</CodeTab>

For subtracting *integers* see the `-` operator.
25 changes: 25 additions & 0 deletions misc_docs/syntax/operators_integer_addition.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: "integer-addition"
keywords: ["plus", "add", "addition", "sum", "int", "integer"]
name: "+"
summary: "This is the `integer addition` operator."
category: "operators"
---

This operator performs *integers* addition.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 1 + 2
```

```js
val result = 3;
```

</CodeTab>

For adding *floats* see the `+.` operator.

For contatenating *strings* see the `++` operator.
25 changes: 25 additions & 0 deletions misc_docs/syntax/operators_integer_division.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
id: "integer-division"
keywords: ["divide", "division", "int", "integer"]
name: "/"
summary: "This is the `integer division` operator."
category: "operators"
---

This operator performs *integer* division, with the result truncated to an integer value.

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.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 3 / 2
```

```js
var result = 1;
```

</CodeTab>

For dividing *floats* see the `/.` operator.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_integer_multiplication.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "integer-multiplication"
keywords: ["multiply", "multiplication", "int", "integer"]
name: "*"
summary: "This is the `integer multiplication` operator."
category: "operators"
---

This operator performs *integer* multiplication.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 2 * 3
```

```js
var result = 6;
```

</CodeTab>

For multiplying *floats* see the `*.` operator.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_integer_subtraction.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "integer-subtraction"
keywords: ["subtract", "minus", "subtraction", "int", "integer"]
name: "-"
summary: "This is the `integer subtraction` operator."
category: "operators"
---

This operator performs *integer* subtraction.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let result = 3 - 2
```

```js
var result = 1;
```

</CodeTab>

For subtracting *floats* see the `-.` operator.
23 changes: 23 additions & 0 deletions misc_docs/syntax/operators_string_concatenation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
id: "string-concatenation"
keywords: ["concat", "concatenation", "add", "string"]
name: "++"
summary: "This is the `string concatenation` operator."
category: "operators"
---

This operator concatenates two *strings* together.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let greetings = "Hello " ++ "world!"
```

```js
var greetings = "Hello world!";
```

</CodeTab>


128 changes: 128 additions & 0 deletions src/components/SyntaxLookupWidget.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bd2a478

Please sign in to comment.