From 890240be6b56858b5a5c9acf9e263ce35da0788d Mon Sep 17 00:00:00 2001
From: Kenny <70860732+KennyOliver@users.noreply.github.com>
Date: Wed, 8 Jan 2025 23:28:43 +0000
Subject: [PATCH 1/3] Fix: Minifier adds space after all keywords including
`create`
#185
---
src/main.c | 42 +++++++++++++++++++++++++++++-------------
1 file changed, 29 insertions(+), 13 deletions(-)
diff --git a/src/main.c b/src/main.c
index 1d76b0e..6c76605 100644
--- a/src/main.c
+++ b/src/main.c
@@ -143,13 +143,13 @@ void minify_tokens(Token *tokens, const char *output_file) {
Token *next = tokens + 1;
while (current->type != TOKEN_EOF) {
+ // Handle the current token
switch (current->type) {
case TOKEN_STRING:
- fputc('"', output); // Opening quote
+ fputc('"', output);
fputs(current->lexeme, output);
- fputc('"', output); // Closing quote
+ fputc('"', output);
break;
-
default:
fputs(current->lexeme, output);
break;
@@ -159,20 +159,36 @@ void minify_tokens(Token *tokens, const char *output_file) {
if (next->type != TOKEN_EOF) {
bool add_space = false;
- if (current->type == TOKEN_KEYWORD &&
- next->type == TOKEN_IDENTIFIER) {
+ // Always add space after keywords
+ if (current->type == TOKEN_KEYWORD) {
+ add_space = true;
+ }
+ // Space between identifiers/literals
+ else if ((current->type == TOKEN_IDENTIFIER ||
+ current->type == TOKEN_STRING ||
+ current->type == TOKEN_INTEGER ||
+ current->type == TOKEN_FLOAT ||
+ current->type == TOKEN_BOOLEAN) &&
+ (next->type == TOKEN_IDENTIFIER ||
+ next->type == TOKEN_STRING ||
+ next->type == TOKEN_INTEGER ||
+ next->type == TOKEN_FLOAT ||
+ next->type == TOKEN_BOOLEAN)) {
add_space = true;
- } else if ((current->type == TOKEN_IDENTIFIER ||
- current->type == TOKEN_STRING ||
- current->type == TOKEN_INTEGER ||
- current->type == TOKEN_FLOAT ||
- current->type == TOKEN_BOOLEAN) &&
+ }
+ // Handle operator spacing
+ else if ((current->type == TOKEN_IDENTIFIER ||
+ current->type == TOKEN_STRING ||
+ current->type == TOKEN_INTEGER ||
+ current->type == TOKEN_FLOAT) &&
+ next->type == TOKEN_OPERATOR) {
+ add_space = false;
+ } else if (current->type == TOKEN_OPERATOR &&
(next->type == TOKEN_IDENTIFIER ||
next->type == TOKEN_STRING ||
next->type == TOKEN_INTEGER ||
- next->type == TOKEN_FLOAT ||
- next->type == TOKEN_BOOLEAN)) {
- add_space = true;
+ next->type == TOKEN_FLOAT)) {
+ add_space = false;
}
if (add_space) {
From ad1b180c43ccdf40f2ff5a7c0b5bba4f64d26ff7 Mon Sep 17 00:00:00 2001
From: Kenny <70860732+KennyOliver@users.noreply.github.com>
Date: Wed, 8 Jan 2025 23:29:15 +0000
Subject: [PATCH 2/3] Update README.md
#185
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 9aee901..682bb8b 100644
--- a/README.md
+++ b/README.md
@@ -205,7 +205,7 @@ npx vsce package
#### 3. Install in VS Code
- Open VS Code.
-- Press Ctrl+Shift+P (or ⌘+⇧+P on macOS) and select Extensions: Install from VSIX….
+- Press ⌘⇧P (CtrlShiftP on Windows) and select Extensions: Install from VSIX….
- Select the generated `.vsix` file within the `vscode-extension` folder.
- Restart your extensions via the popup notification.
From 650f25ee10e659a1b8529d99304d9f5bb410ca9c Mon Sep 17 00:00:00 2001
From: Kenny <70860732+KennyOliver@users.noreply.github.com>
Date: Wed, 8 Jan 2025 23:29:53 +0000
Subject: [PATCH 3/3] Update README.md
#185
---
README.md | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/README.md b/README.md
index 682bb8b..00e5814 100644
--- a/README.md
+++ b/README.md
@@ -77,7 +77,7 @@ FlavorLang blends coding with culinary creativity! Write programs like recipes &
```bash
-./install.sh
+$ bash install.sh
```
##### 3. Handle macOS Security Prompt (If Any)
@@ -88,7 +88,7 @@ FlavorLang blends coding with culinary creativity! Write programs like recipes &
##### 4. Verify Installation
```bash
-flavor --about
+$ flavor --about
```
#### For Ubuntu Users
@@ -102,13 +102,13 @@ flavor --about
```bash
-./install.sh
+$ bash install.sh
```
##### 3. Verify Installation
```bash
-flavor --about
+$ flavor --about
```
#### Make it Yourself
@@ -190,8 +190,8 @@ $ flavor --about # About FlavorLang
Navigate to the `vscode-extension` folder and install dependencies:
```bash
-cd vscode-extension
-npm install
+$ cd vscode-extension
+$ npm install
```
#### 2. Package the Extension
@@ -199,7 +199,7 @@ npm install
Use vsce (Visual Studio Code Extension Manager) to build the `.vsix` package:
```bash
-npx vsce package
+$ npx vsce package
```
#### 3. Install in VS Code