diff --git a/README.md b/README.md index ce013e5..10325f8 100644 --- a/README.md +++ b/README.md @@ -1,302 +1,423 @@ # 🌊 The Fyshhiker's Guide to the Ocean 🐋 + +## Introduction + +**Fysh** is an esoteric programming language that embraces creativity and a playful theme. It uses fish-related symbols and terms to represent programming concepts. This guide aims to provide a clear understanding of Fysh's syntax and features while maintaining its fun and engaging spirit. + +--- + ## 👩‍💻 How to Compile and Run Fysh ### ⚙️ Option 1: Using VSCode -1. Download the `Fysh` VSCode extension. -2. Create a `.fysh` file. -3. Write your code. -4. Press the run button. +1. **Download the Fysh VSCode Extension** + - Install the Fysh extension from the VSCode marketplace. + +2. **Create a `.fysh` File** + - Open VSCode and create a new file with the extension `.fysh`. + +3. **Write Your Code** + - Start coding in Fysh! + +4. **Run Your Code** + - Press the run button provided by the extension to execute your program. + ### ⚙️ Option 2: Using Command Line +1. **Install the Latest Version of Fysh** + - Use the Go command to install Fysh: + + ```bash + go install github.com/Fysh-Fyve/fysh@latest + ``` -1. Install the latest version `go install github.com/Fysh-Fyve/fysh@latest` -2. Execute with `fysh .fysh`. +2. **Execute Your Fysh Program** + - Run your program using the generated Fysh interpreter: + ```bash + fysh .fysh + ``` + +--- ## 🐙 Fyshing Manual -### 🐠 Chapter 1: Fysh Syntax +### 💬 Chapter 1: Comments + +
+ Click to expand + +#### 🔉 Single-line Comments + +Single-line comments start with navigator fish `>`. + +```fysh +> What's cookin' good lookin'? +``` + +#### 🔊 Multi-line Comments + +For longer explanations, multiline comments are used. They are enclosed with +`>` and `<*\><` + +```fysh +> +How to grill a Fysh: +1. Catch a Fysh +2. Grill the Fysh +3. Eat the Fysh +<*/>< +``` + +
+ + +### 🐠 Chapter 2: Fysh Syntax
Click to expand #### 🐟 Variables -- Meet Steven, our fishy friend. In Fysh, variables like Steven are declared - with `>`. Every line of fysh ends with a wave `~`. +In Fysh, variables are declared using the syntax `>`. Every line of Fysh code ends with a tilde `~`. +**Example:** ```fysh > ~ ``` -- Steven has binary scales. In Fysh, `}` represents `1` and `)` represents `0`. - Here, Steven is valued at `0b101`, which is `5` in decimal. +#### 👉🏻 Assigning Values +Variables can be assigned values using either the `≈` or `=` operator. +**Example:** +`Steven` is assigned the value of `CoolFysh`: ```fysh -> = ><})}> ~ +> ≈ > ~ ``` -- Steven doesn’t give a flying fysh about scale direction. `≈` for variable - assignment is cool with them too. +#### 🔟 Binary Scales + +A fysh's scales represents it's binary value `><})}>`: + +- **Scales Representing Binary 1:** `{` and `}` +- **Scales Representing Binary 0:** `(` and `)` + +> **Note:** The direction of the scales does not matter. `{` and `}` both represent binary `1`, and `(` and `)` both represent binary `0`. + +**Example:** + +Here we assign the binary value `0b101` (5 in decimal) to `Steven`: ```fysh -> ≈ ><}({> ~ +> ≈ ><})}> ~ ``` #### 👁️ Optional Visuals -- Steven is blind. You have the power to bless them with sight, but it's - completely optional! You can make them biblically accurate by giving them - multiple eyes. +`><})}>` is blind, but we can give it eyes... multiple eyes! 🐟👀 +**Valid Eye Symbols:** `o`, `°` +> **Note:** This is completely optional. ```fysh -> ≈ ><{({°> ~ -> ≈ ><{({o> ~ -> ≈ ><{({°°> ~ -> ≈ ><{({o°> ~ -> = ><{({°o°> ~ +> ≈ ><})}°> ~ +> ≈ ><{({°> ~ +> ≈ ><{({o> ~ +> ≈ ><{({°°> ~ +> ≈ ><{({o°> ~ +> ≈ ><}({°o°> ~ ``` +
-#### ➕ Arithmetic with Variables - -- **Summing values:** A school of Fysh's value is the sum of each member. This - gives Steven a value of `0b101 = 0b100 + 0b001 =` (5 = 4 + 1). +### ➕ Chapter 3: Arithmetics +
+ Click to expand +#### Addition +To add two fyshes, place variables or values next to each other. The value of a school of Fysh is the sum of each member. +**Example:** +steven = 4 + 1 (binary: `0b100` + `0b001`) ```fysh > ≈ ><{((°> ><(({°> ~ ``` +In this example: -- **Subtracting values:** Sometimes fysh are negative and start to swim - backwards. This takes away from the school's value. Steven's value is - `0b101 = 0b111 - 0b010` (5 = 7 - 2). +- `><{((°>` represents `0b100` (4) +- `><(({°>` represents `0b001` (1) +- `steven` is assigned `4 + 1 = 5` +#### ➖ Subtraction +Some fysh are negative and start to swim away. Fysh swimming to the left take away from the school's value. +> **Note:** Fysh swim to the left flips the sign of the fysh. So a negative variable swimming left will become positive. + +**Example:** +steven = 7 - 2 (binary: `0b111` - `0b010`) ```fysh -> ≈ ><{{{°> <°)})>< ~ # 0b101 = 0b111 - 0b010 +> ≈ ><{{{°> <°)})>< ~ ``` +#### ❤️ Multiplication +Fysh often get lonely. This loneliness causes fysh to meet new fysh and proliferate, quickly multiplying their numbers. +> **Note:** Every possible representation of a heart is valid for multiplication. If there's a heart that doesn't work, please let us know. -- **Multiplying values:** Fysh often get lonely. This loneliness causes fysh to - meet new fysh and proliferate. This gives Steven a value of - `0b101010 = 0b110 * 0b111`. (42 = 6 * 7) - +**Example:** +steven = 6 * 7 (binary: `0b110` * `0b111`) ```fysh > = ><{{(°> <3 ><{{{°> ~ > ≈ ><{{(°> ♡ ><{{{°> ~ +> ≈ ><{{(°> 💘 ><{{{°> ~ ``` -- **Dividing values:** Not every fysh story is a happy one. At times, separation - is inevitable, and their division breaks their heart. This gives Steven a - value of `0b101 = 0b11001 / 0b101`. (5 = 25 / 5) +#### 💔 Division +Not every fysh story is a happy one. At times, separation is inevitable, and their division breaks their hearts, causing their numbers to dwindle. +Division is represented by a broken heart ` ≈ ><{{(({°> <{({°> ~ > ≈ ><{{(({°> 💔 ><{({°> ~ ``` -- **Using parentheses for complex operations:** Fysh are often abducted and - isolated into fyshbowls `( )` for terrestrials' amusment. This makes the fysh - sad and gives Steven a value of `0b101 = 0b101 / (0b101 - 0b100)`. (5 = 5 / - (5 - 4)) +#### 🎣 Fysh Bowls (Parentheses) +Fysh are often abducted and kept in small glass fysh bowls for the amusement of land-dwellers. These bowls are represented by `( )`. +This is used to group fysh together, allowing their operations to be performed first. + +**Example:** +steven = 5 / (5 - 4) (binary: `0b101` / (`0b101` - `0b100`)) ```fysh > ≈ ><{({°> 💔 ( ><{({°> <°}))>< ) ~ ``` -#### 🔼🔽 Increment and Decrement -- **Increment:** As life goes on, we learn from our mistakes and improve. +#### 📈 Increment + As life goes on, we learn from our mistakes and improve. Steven’s self help journey allowed them to grow an extra tail, incrementing their value by 1. +**Example:** +steven = steven + 1 ```fysh >> ~ ``` -- **Decrement:** Sometimes we feel like a fyshup, a failure. And that's ok, it’s +#### 📉 Decrement + Sometimes we feel like a fyshup, a failure. And that's ok, it’s a part of being fysh. However for some fysh, this feeling is too much to handle and is internalized. They haven’t received the emotional support they need and have gone on a downward spiral, causing them to feel worthless. They begin to retreat and try to swim away in the opposite direction causing their value to decrement by 1. +**Example:** +steven = steven - 1 ```fysh << ~ ``` #### 🍢 Random Number Generation +The random number generator is represented with a grilled fysh. It generates a random signed 32-bit number that determines the doneness of the fysh. -**Random Number:** This is a grilled fysh. It generates a random signed 32-bit -number that determines the doneness of the fysh. - +**Example:** ```fysh ><####> ~ ```
-### 📊 Chapter 2: Data Types +### ⚓ Chapter 3: Output
Click to expand -#### 📏 Integers +#### ⛓️ Output Value + +To output the value of a variable, use an anchor `(+o` or `⚓`. -- **Integer:** Steven is an integer represented using binary scales. They have - scales that are either `1` or `0`. Steven's value is `0b101`, which is `5` in - decimal. + +**Example:** +Output the value of `Steven`: ```fysh -> ≈ ><{({°> ~ +(+o ><{({°> ~ ``` -#### 📐 Floating Point Numbers +
+ -- **Floats:** Steven can also be a float fysh. To seperate the integer and - decimal parts, we use a fysh bone `-`. Steven's value is `5.5`. +### 📊 Chapter 4: Data Types +
+ Click to expand + +#### 📏 Integers + Fysh with binary scales `><})}>` are integers. + +**Example:** +Steven = 5 (binary: `0b101`) ```fysh -> ≈ ><{({-{({°> ~ +> ≈ ><{({°> ~ ``` -- **Floats with multiple bones:** Steven can also have multiple bones to - seperate each decimal place. Steven's value is `5 + 0.2 + 0.05 = 5.25`. +#### 🦴 Floats with One Bone + Some people like to play with their food, so they pick away at steven, leaving only a fraction of them behind. This exposes the bones (`-`) of the fysh. Bones help to separate the integer and decimal parts of the fysh. +**Example:** ```fysh -> ≈ ><{({-{(-{({°> ~ +> ≈ ><{{{-{({°> ~ ``` +Explanation: + +- `><{{{-` represents the integer part `7` (binary: `0b111`) +- `-{({°>` represents the fractional part `0.5` (binary: `0b101`) +- Steven's value is `7 + 0.5 = 7.5`. -- **Floats with numbers larger than 9:** If a value in the decimal place is - greater than 9, it will occupy an extra decimal place. Steven's value is - `15 + 0.15 + 0.005 15.155`. +#### 🦴🦴🦴 Floats with Multiple Bones +When multiple bones are present, the additonal values are added at the end of the decimal part. Steven's value is `2 + 0.15 + 0.005 = 15.155`. +**Example:** ```fysh -> ≈ ><{{{{-{{{{-{({°> ~ +> ≈ ><{(-{{{{-{{{°> ~ ``` +Explanation: -#### 📝 Strings +- `><{(-` represents the integer part `2` (binary: `0b10`) +- `-{{{{-` represents the fractional part `0.15` (binary: `0b1111`) +- `-{{{°>` represents the additional fractional part `0.007` (binary: `0b111`) +- steven's value is `2 + 0.15 + 0.007 = 2.157`. -- **Strings:** Steven can also be a string fysh. They speak using bubbles. - Steven's value is `"Hello, World!"`. +#### 🫧 Bubbles (Strings) +Fysh blow bubbles, and these bubbles can be used to represent strings. +Bubble strings are enclosed in `🫧` or `*`. +**Example:** ```fysh > ≈ 🫧Hello, World!🫧 ~ > = *Hello, World!* ~ ``` #### 📦 Arrays and Traversal +Arrays are represented by a fysh tank `[ ]`. Each item is separated + by fysh food `-`. -- **Arrays:** A fysh tank `[ ]` is used create an array. Each item is separated - by fysh food -.value is `[0b010, 0b010] = [2, 2]`. - +**Example:** +steven = [6,2] (binary: `[0b110, 0b010]`) ```fysh -> ≈ [><({(°> - ><({(°>] ~ +> ≈ [><{{(°> - ><({(°>] ~ ``` -- **Accessing Array Elements:** These fysh tanks can be traversed using a fysh - tank `[ ]` with a number inside it. Steven returns the element at index 1. - Array indexes start at 0. + To access array elements, use the array variable followed by `[index]`. +> **Note:** Array indexes start at 0. +**Example:** +steven[1] (accessing the second element of steven) ```fysh >[><(({°>] ~ ``` -
-### 🧠 Chapter 3: Fysh Logic and Operations +### 🧠 Chapter 5: Fysh Logic and Operations
Click to expand +#### 🐸 Tadpoles + +The greater than and less than operations are represented by tadpoles `~o` and `o~`. Tadpoles swim towards the bigger Fysh, indicating the direction of the comparison. + +**Example:** +```fysh +> Greater/Less than +> o~ ><{({°> ~ > Steven > 1 +> ~o ><{{{°> ~ > Steven < 7 + +> Greater/Less than or equal to (replace ~ with ≈ or =) +> o≈ ><{({°> ~ > Steven >= 1 +> =o ><{{{°> ~ > Steven <= 7 +``` + #### 🤔 Logical Operations -- **`AND (&&)`, `OR (||)`, and `NOT (!!)`**: Steven is experiencing an - existential crisis. They're questioning the very fabric of reality. - - If steven is real `and` they found the truth, they're happy. (Steven && - theTruth) - - Steven is happy if either they're real `or` found the truth. (Steven || - theTruth) - - But then Steven thought about it and said "hey it would be kinda cool if I - wasn't real" and is now only happy if they're `not` real. (!!Steven) +Fysh supports standard logical operations: +- **AND**: `&&` +- **OR**: `||` +- **NOT**: `!!` + +**Example:** ```fysh -> && > ~ -> || > ~ -!! > ~ +> && > ~ > Steven and Alive +> || > ~ > Steven or Alive +!! > ~ > Not Steven ``` #### 🔧 Bitwise Operations -- Steven is bored and looking to have their bits rearranged. At Fysh, we're - hereto help! We have provided Steven with a variety of tools and bitwise + Steven is bored and looking to have their bits rearranged. At Fysh, we're + here to help! Steven has been provided with a variety of tools and bitwise manipulations to satisfy their bit busting needs: - `AND (&)` - `OR (|)` - `XOR (^)` - `NOT (!)` + +> **Note:** Currently does not support floats ```fysh -> & ><(({°> ~ -> | ><(({°> ~ -> ^ ><(({°> ~ -! > ~ +> & ><(({°> ~ > Steven and 1 +> | ><(({°> ~ > Steven or 1 +> ^ ><(({°> ~ > Steven xor 1 +! > ~ > Not Steven ``` - -- **Logical shifts:** Steven can also use logical shifts! Steven shifts their +#### 🔄 Logical Shift Operations + You can even use logical shifts! Steven shifts their bits to the left then right by 1. - **Left shift (`<<`):** - **Right shift (`>>`):** -```fysh -> << ><(({°> ~ -> >> ><(({°> ~ -``` - -#### 🐸 Tadpoles -Tadpoles are Fysh too. They swim towards bigger Fysh (they like the danger) and -are represented by `~o` or `o~`. Here, we are checking if Steven is bigger than -5 and less than 7, respectively. +> **Note:** Currently does not support floats +**Example:** ```fysh -> Greater/Less than -> o~ ><{({°> -> ~o ><{{{°> - -> Greater/Less than or equal to (replace ~ with ≈ or =) -> o= ><{({°> -> ≈o ><{{{°> +> << ><(({°> ~ > Steven left shift 1 +> >> ><(({°> ~ > Steven right shift 1 ``` -
-### 🔄 Chapter 3: Control Structures +### 🔄 Chapter 6: Control Structures
Click to expand #### 🔁 While Loops -- In the whirlpool of Fysh logic, the while loop, represented by `@`, `🌀`, or `><(((@>` - with the condition stored in either `[ ]` or `( )`. Small fysh define the - iterative heart `><>` and `<><`. + While loops can be represented using whirlpools: + +- `@` +- `🌀` +- `><(((@>` -Here we repeat the loop while Steve is greater than 5. Steven decrements by 1 -each iteration. +The condition stored in either: +- `( )` fysh bowl +- `[ ]` fysh tank +The loop body is enclosed between `><>` and `<><`. + +**Example:** ```fysh -🌀 [> o~ ><{((°>] +🌀 [> o~ ><{((°>] > while steven > 4 ><> - << ~ + << ~ > steven-- <>< -@ (> o~ ><{((°>) +@ (> ~o ><{((°>) > while steven < 4 ><> - << ~ + >> ~ > steven++ <>< -><(((@> [> o~ ><{((°>] +><(((@> [> o≈ ><{((°>] > while steven >= 4 ><> - << ~ + << ~ > steven-- <>< ``` @@ -304,154 +425,164 @@ each iteration. Conditional statements run based on how each Fysh feels -- **`if` statement:** are happy since they're the condition you're looking for. - They feel wanted and loved. They are represented by a happy Fysh +##### 😊 **`if` Statements: The Happy Fysh `><(((^>`** +These Fysh are overjoyed because they're the center of attention—they feel wanted and loved. +**Example:** ```fysh -><(((^> [> o~ ><{((°>] +><(((^> [> o~ ><{((°>] > if steven > 4 ><> - << ~ + << ~ > steven-- <>< ``` -- **`else` statement:** feel like they're the last resort, an afterthought. This - makes them feel unimportant and sad. They are represented by a dead Fysh +##### 😵 **`else` Statement: The Sad (Dead) Fysh `><(((*>`** +These fysh feel like they're an afterthought and are often left behind. This makes them feel sad and dead inside. +**Example:** ```fysh -><(((*> +><(((*> > else ><> - > ≈ ><(((°> ~ + > ≈ ><(((°> ~ > steven = 0 <>< ``` -- **`else if` statement:** are the middle child. They're not the first choice, - but they're not the last either. They're represented by both a dead and happy - Fysh +##### 😐 **`else if` Statement: The Middle Child `><(((*> ><(((^>`** +These fysh are a combination of a dead and a happy fish, symbolizing the middle child. Not the first choice but not the last. ```fysh -><(((*> ><(((^> [> ~o ><{((°>] +><(((*> ><(((^> [> ~o ><{((°>] > else if steven < 4 ><> - >> ~ + >> ~ > steven++ <>< ```
-### 🧑‍🔧 Chapter 4: Functions +### 🧑‍🔧 Chapter 7: Functions
Click to expand #### ✏️ Defining Functions -To define a function or SUBroutine, use a submarine `>(funcNameHere)` along with -any parameters `>`. To return a value, use a squid `<~` or `🦑`. -Here the function is called `submarine` and has 3 parameters. It returns the sum -of the 3 parameters. +Functions (subroutines) are defined using a submarine `>(functionName)`, with parameters `>`. The function body is enclosed between `><>` and `<><`. To return a value, use a squid `<~` or `🦑`. +**Example:** ```fysh ->(submarine) > > > +>(add) > > > def add(param1, param2) ><> - <~ > > > ~ + <~ > ♡ > ~ > Return the product of param1 and param2 <>< ``` #### 📞 Calling Functions -- To call a subroutine, put the submarine in a Fysh tank along with its - arguments. If two or more params are next to each other, separate them with - Fysh food `-`. +To call a function, place the submarine in a fish tank `[ ]`, along with its arguments, separated by fish food `-`. + +> **Note:** The submarine can be placed anywhere in the fish tank as long as the arguments are in the correct order. +**Example:** ```fysh -[>(submarine) > - > - >] ~ +[>(submarine) > - >] ~ > submarine(fysh1, fysh2) ```
-### ⚓ Chapter 5: Output + + +### 📈 Examples
Click to expand -#### ⛓️ Output Value +
+ ❗Factorial Example -When we finally reach our destination, we anchor ourselves. Anchors are used to -output the value of a Fysh. They are represented by `(+o` or `⚓` +#### ❗Factorial Example -Here we're outputting `0b101` (5). +This program calculates the factorial of a number, in this case, 5. The factorial of 5 is 120. ```fysh -(+o ><{({°> ~ -``` - -
- -### 💬 Chapter 6: Comments - -
- Click to expand +> Factorial Example -#### 🔉 Single-line Comments +> ≈ ><{({°> ~ > number = 5 +> ≈ ><(({°> ~ > factorial = 1 -Navigator Fysh are used to guide the reader through the code. They are -represented by `>`. +🌀 [> o~ ><(({°>] +><> + > ≈ > ♡ > ~ > factorial = factorial * number + << ~ > number-- +<>< -```fysh -> What's cookin' good lookin'? +⚓ > ~ > print(factorial) ``` -#### 🔊 Multi-line Comments +**Explanation:** -For longer explanations, multiline comments are used. They are represented by -`>` and `<*\><` +1. **Variable Declarations:** + - `> ≈ ><{({°> ~` assigns 5 to `number`. + - `> ≈ ><(({°> ~` assigns 1 to `factorial`. -```fysh -> -How to grill a Fysh: -1. Catch a Fysh -2. Grill the Fysh -3. Eat the Fysh -<*/>< -``` +2. **While Loop:** + - `🌀 [> o~ ><(({°>]` loops while `number` > 1. + - Inside the loop: + - Multiply `factorial` by `number`. + - Decrement `number`. -
+3. **Output:** + - `⚓ > ~` outputs the calculated factorial. -### 📈 Examples +
- Click to expand - -#### ❗Factorial Example + 🔁Fibonacci Example (recursion) + +#### 🔁Fibonacci Example -This program calculates the factorial of number. In this case 5. The factorial -of 5 is 120. +This program calculates the nth Fibonacci number, in this case, the 7th. The 7th Fibonacci number is equal to 13. ```fysh -> Factorial Example - -> ≈ ><{({°> ~ -> ≈ ><(({°> ~ +> Fibonacci Example -🌀 [> o~ ><(({°>] +>(fib) > > def fib(n) ><> - > ≈ > ♡ > ~ - << ~ + ><(((^> [> ~o ><({(°>] > if n < 2 + ><> + 🦑 > ~ > Return 'n' if 'n' < 2 + <>< + ><(((*> > else + ><> + > ≈ [>(fib) > <({><] ~ > a = fib(n - 1) + > ≈ [>(fib) > <{(><] ~ > b = fib(n - 2) + 🦑 > > ~ > Return a + b + <>< <>< -(+o > ~ + +> ≈ [>(fib) ><{{{°>] ~ > result = fib(7) +⚓ > ~ > print(result) ``` -Let's break it down: +**Explanation:** -1. `> ≈ ><{({°> ~` - Declare the number to calculate the factorial of. - (5 in this case) -2. `> ≈ ><(({°> ~` - Declare the factorial variable. (1 in this case) -3. `🌀 [> o~ ><(({°>]` - While the number is greater than 1, do the - following: - 1. `> ≈ > ♡ > ~` - Multiply the factorial by - the number. - 2. `<< ~` - Decrement the number. - 3. Repeat until the number is 1. -4. `(+o > ~` - Output the factorial. +1. **Function Definition:** + - `>(fib) >` defines the function `fib` with parameter `n`. + - If `n` is less than 2: + - Return `n`. + - Else: + - Compute `a = fib(n - 1)`. + - Compute `b = fib(n - 2)`. + - Return `a + b`. +2. **Function Call:** + - `> ≈ [>(fib) ><{{{°>] ~` calls `fib(7)` and assigns the result to `result`. result = fib(7) + +3. **Output:** + - `⚓ > ~` outputs the 7th Fibonacci number (13). +
+ +--- + +This concludes the **Fyshhiker's Guide to the Ocean**. Happy Fyshing! \ No newline at end of file