Skip to content

Commit

Permalink
add syntax highlighting for jule code snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
mertcandav committed Aug 9, 2023
1 parent 3032762 commit cd47110
Show file tree
Hide file tree
Showing 79 changed files with 706 additions and 713 deletions.
2 changes: 1 addition & 1 deletion src/api/integrated-jule/wrappers.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public:
You can integrate and use your wrappers by linking them to your Jule code according to the information described in the [interoperability](/cpp/interoperability/) section of manual.
Integrating the STL Vector wrapper described above with Jule would look like this:
```
```jule
cpp use "vector.hpp"
//jule:typedef
Expand Down
8 changes: 4 additions & 4 deletions src/common-concepts/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ The array for storing a fixed size sequence of elements.
[CONST_SIZE_EXPRESSION]DATA_TYPE
```
For example:
```
```jule
[50]int
```

## Triple Dot for Auto Computing Size of Array Literals
You can use `...` for auto computing size of array literal at compile time.

For example:
```
```jule
let x: [...]int = [1, 2, 3, 4, 5] // [5]int
```

Expand All @@ -24,7 +24,7 @@ Index system is simple. Starts at `0` and continue step by step, it is never not
Arrays is use indexes to access elements and assignment.

For example:
```
```jule
fn main() {
let mut my_array: [3]str = ["Hello", "arrays", "indexes"]
outln(my_array[0])
Expand All @@ -44,7 +44,7 @@ Hello
Multidimensional arrays is array storing arrays.

For example:
```
```jule
fn main() {
let my_array: [2][2]str = [
["Apple", "Banana"],
Expand Down
6 changes: 3 additions & 3 deletions src/common-concepts/control-flow/conditional.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ If expressions allow you to manipulate the algorithm according to certain condit
If the provided condition is `true` the block is executed, otherwise it is not executed. It is also the beginning of a new chain of conditions.

For example:
```
```jule
fn main() {
let x: Error
if x == nil {
Expand All @@ -18,7 +18,7 @@ fn main() {
If the preceding `if` and `else if` expressions have not been fulfilled, it is a condition presented as an alternative to them.

For example:
```
```jule
fn main() {
let x = 100
if x > 1000 {
Expand All @@ -37,7 +37,7 @@ fn main() {
It is the block that will be executed unconditionally if the previous `if` and `else if` expressions are not fulfilled.

For example:
```
```jule
use std::errors
fn main() {
Expand Down
16 changes: 8 additions & 8 deletions src/common-concepts/control-flow/iterations.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Iterations allow you to repeat the algorithm according to certain conditions. Th
Infinite iterations keep repeating endlessly until the loop is somehow broken.

For example:
```
```jule
fn main() {
for {
outln("Hello, iterations")
Expand All @@ -18,7 +18,7 @@ The above example prints `Hello, iterations` repeatedly.
The while iterations are iterations that repeat as long as a certain condition is met. It is not much different from defining an infinite iteration.

For example:
```
```jule
fn main() {
let mut counter = 0
for counter <= 5 {
Expand All @@ -35,7 +35,7 @@ If you've ever used a programming language, you're probably familiar with for lo
While-next is almost the same as a classic while iteration. In this, the only addition is to be able to write an expression that will happen after the iteration step. While-next's statement is separated by the statement terminator. First comes the condition expression, then statement.

For example:
```
```jule
fn main() {
let mut i = 1
for i <= 5; i++ {
Expand All @@ -51,7 +51,7 @@ Foreach or for-each can be summarized as an iteration standard for collections.
Each identifier used for foreach is used to create a new variable. So if there is a definition that already has this identifier, it will be shaded.

For example:
```
```jule
fn main() {
let s = "Hello"
for i in s {
Expand All @@ -72,7 +72,7 @@ Iterations can have two variables: Current index and current element.
This example, just shows index. Let's see foreach iteration with content.

For example:
```
```jule
fn main() {
let s = "Hello"
for _, b in s {
Expand All @@ -97,7 +97,7 @@ Jule assign variables data types by automatically by collection. Similar to type
Foreach iterations have immutable variables by default. But you may want to get them as mutable. For this, enclose the identifiers in parentheses and qualify the variable you want to be mutable as mutable.

For example:
```
```jule
fn main() {
let s = "Hello"
for (_, mut b) in s {
Expand All @@ -112,7 +112,7 @@ We may want to check for iterations, this is normal and common. There are two wa
If you want break the iteration, use the `break` keyword.

For example:
```
```jule
fn main() {
for {
outln("Hello, World")
Expand All @@ -127,7 +127,7 @@ The example at above, normally prints `Hello, World` again and again. But just p
If you want continue to next iteration, use the `continue` keyword.

For example:
```
```jule
fn main() {
for {
continue
Expand Down
4 changes: 2 additions & 2 deletions src/common-concepts/control-flow/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For example: `goto repeat`
When using nested iterations or match expressions, the keywords `break` and `continue` are targeted to the last valid block. This makes it harder to target outer loops or the match expression.

For example:
```
```jule
fn main() {
for {
match {
Expand All @@ -36,7 +36,7 @@ An infinite iteration appears in this example. The `break` keyword inside the ma
Again, label can be used to clear up this confusion. This is a more maintainable and clearer solution. Labels defined before an iteration and match expression can be used for targeting.

For example:
```
```jule
fn main() {
loop:
for {
Expand Down
14 changes: 7 additions & 7 deletions src/common-concepts/control-flow/match-statement.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
If you need to make a selection and run an algorithm based on that selection, `match` is a good choice. The operator `|` is used for each case. For a block to be executed if not exist any match, don't give any expression to one case.

**Syntax**
```
```jule
match EXPRESSION {
| CASE_EXPRESSION1: // Body
| CASE_EXPRESSION2: // Body
Expand All @@ -17,7 +17,7 @@ match EXPRESSION {
**No expression case**: Default block.

For example:
```
```jule
match my_integer {
| MY_INTEGER_MIN: outln("Minimum")
| MY_INTEGER_MAX: outln("Maximum")
Expand All @@ -29,7 +29,7 @@ match my_integer {
As with iterations, you can break the execution of the block. The keyword `break` is sufficient for this.

For example:
```
```jule
match X {
| Y:
if Y == A {
Expand All @@ -45,7 +45,7 @@ match X {
If a match expression is not given, match acts like an if-else chain. This might be a more readable option on long condition chains.

For example:
```
```jule
match {
| x > 10 || x < 90:
// Body
Expand All @@ -62,7 +62,7 @@ match {
You can have a single algorithm for multiple cases. For this, you can give more than one expression for a case. The only addition in syntax is vline operator (`|`) between expressions.

For example:
```
```jule
match X {
| Y | Z | V:
// Body
Expand All @@ -79,7 +79,7 @@ match X {
The fall keyword can only useable into case scopes and end of the scopes. It continues to next scope.

For example:
```
```jule
match {
| false:
outln("Case1")
Expand All @@ -105,7 +105,7 @@ Default
The `any` data type may contain any data and you may want to execute different algorithms based on this data, in which case type matching is useful. You can also determine types of trait's data. Type matching is easy. Just use the keyword `type` and then use the data type in case to match.

For example:
```
```jule
fn main() {
let x: any = 10
match type x {
Expand Down
6 changes: 3 additions & 3 deletions src/common-concepts/enums.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Enumerations are a structure that allows to collect numeric constant values together. This increases the readability of the code and makes it easier to maintain. The keyword enum is used to declare an enum.

For example:
```
```jule
enum FileMode {
Read = 35,
Write = 89,
Expand All @@ -26,7 +26,7 @@ You can't use any global, function or etc. in custom value expressions.
If you want to give enums a data type other than the default, it is possible to do so.

For example:
```
```jule
enum FileMode: u8 {
Read,
Write,
Expand All @@ -48,7 +48,7 @@ The default values ​​of enums are always what is the default value of the da
## Casting
You may want to cast your enum for various reasons. Normal casting rules apply here. When casting an enum value, it is based on the enum value type.

```
```jule
enum MyEnum {
MyVal = 10
}
Expand Down
Loading

0 comments on commit cd47110

Please sign in to comment.