diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..70e63ff --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Set default behavior to automatically normalize line endings. +* text=auto diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml new file mode 100644 index 0000000..b91cb04 --- /dev/null +++ b/.github/workflows/build-release.yaml @@ -0,0 +1,90 @@ +name: Build and Release VSIX + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '16' + + - name: Install vsce + run: npm install -g @vscode/vsce + + - name: Install dependencies + run: npm install + + - name: Determine Version Bump + id: version + run: | + $comment = "${{ github.event.head_commit.message }}" + if ($comment -match "#major") { + echo "bumpType=major" >> $GITHUB_OUTPUT + } elseif ($comment -match "#minor") { + echo "bumpType=minor" >> $GITHUB_OUTPUT + } else { + echo "bumpType=patch" >> $GITHUB_OUTPUT + } + + - name: Execute Update Script + id: update + run: | + $DebugInfo = @() + $DebugInfo += "Executing update.ps1 with VersionType=${{ steps.version.outputs.bumpType }}" + $result = pwsh ./scripts/update.ps1 -VersionType ${{ steps.version.outputs.bumpType }} + echo "version=$result" >> $GITHUB_OUTPUT + echo "$DebugInfo" >> $GITHUB_STEP_SUMMARY + shell: pwsh + + - name: Validate Version Output + id: validate + run: | + $version = "${{ steps.update.outputs.version }}" + echo "Validating version: $version" >> $GITHUB_STEP_SUMMARY + if ($version -notmatch "^\d+\.\d+\.\d+$") { + Write-Error "Invalid version format: $version" + exit 1 + } + echo "newVersion=$version" >> $GITHUB_OUTPUT + + - name: Build VSIX file + run: | + vsce package --out dist/blazium-anko-extension-${{ steps.validate.outputs.newVersion }}.vsix + + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: blazium-anko-extension-vsix + path: dist/blazium-anko-extension-${{ steps.validate.outputs.newVersion }}.vsix + + release: + needs: build + runs-on: windows-latest + + steps: + - name: Download artifact + uses: actions/download-artifact@v3 + with: + name: blazium-anko-extension-vsix + + - name: Create GitHub Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.validate.outputs.newVersion }} + release_name: Blazium Anko Extension v${{ steps.validate.outputs.newVersion }} + draft: false + prerelease: false + files: dist/blazium-anko-extension-${{ steps.validate.outputs.newVersion }}.vsix diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a857b2c --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/dist/*.vsix +node_modules diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..337dd2b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Run Anko Extension", + "type": "extensionHost", + + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/anko" + ] + }, + { + "name": "Reload Anko Extension", + "type": "extensionHost", + "request": "launch", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/anko", + "--disable-extensions" + ] + } + ] +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..39e99d9 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,58 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "Package Anko Extension", + "type": "shell", + "command": "vsce", + "args": [ + "package", + "--allow-missing-repository", + "--out", + "${workspaceFolder}/dist/blazium-anko-extension-0.1.0.vsix" + ], + "options": { + "cwd": "${workspaceFolder}/anko" + }, + "problemMatcher": [], + "group": { + "kind": "build", + "isDefault": true + }, + "detail": "Packages the Anko extension into a .vsix file and places it in the 'dist' folder." + }, + { + "label": "Install Anko Extension", + "type": "shell", + "command": "code", + "args": [ + "--install-extension", + "${workspaceFolder}/dist/blazium-anko-extension-0.1.0.vsix" + ], + "problemMatcher": [], + "detail": "Installs the packaged Anko extension from the 'dist' folder." + }, + { + "label": "Reload Anko Extension", + "type": "shell", + "command": "code", + "args": [ + "--extensionDevelopmentPath=${workspaceFolder}/anko", + "--disable-extensions" + ], + "problemMatcher": [], + "detail": "Reloads the Anko extension for development." + }, + { + "label": "Uninstall Anko Extension", + "type": "shell", + "command": "code", + "args": [ + "--uninstall-extension", + "blazium-engine.anko" + ], + "problemMatcher": [], + "detail": "Uninstalls the Anko extension from VS Code." + } + ] +} diff --git a/.vscodeignore b/.vscodeignore new file mode 100644 index 0000000..f369b5e --- /dev/null +++ b/.vscodeignore @@ -0,0 +1,4 @@ +.vscode/** +.vscode-test/** +.gitignore +vsc-extension-quickstart.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8ab70c0 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ +MIT \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..b238004 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +This is the Blazium Anko Syntax Highlighter cause we need one.. + +I do this for Dragos! + + +ALL HAIL THE GREAT DRAGOS~ \ No newline at end of file diff --git a/anko/CHANGELOG.md b/anko/CHANGELOG.md new file mode 100644 index 0000000..3202edd --- /dev/null +++ b/anko/CHANGELOG.md @@ -0,0 +1,9 @@ +# Change Log + +All notable changes to the "anko" extension will be documented in this file. + +Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. + +## [Unreleased] + +- Initial release \ No newline at end of file diff --git a/anko/LICENSE.md b/anko/LICENSE.md new file mode 100644 index 0000000..8ab70c0 --- /dev/null +++ b/anko/LICENSE.md @@ -0,0 +1 @@ +MIT \ No newline at end of file diff --git a/anko/README.md b/anko/README.md new file mode 100644 index 0000000..b238004 --- /dev/null +++ b/anko/README.md @@ -0,0 +1,6 @@ +This is the Blazium Anko Syntax Highlighter cause we need one.. + +I do this for Dragos! + + +ALL HAIL THE GREAT DRAGOS~ \ No newline at end of file diff --git a/anko/language-configuration.json b/anko/language-configuration.json new file mode 100644 index 0000000..5f30401 --- /dev/null +++ b/anko/language-configuration.json @@ -0,0 +1,59 @@ +{ + "comments": { + "lineComment": "//", + "blockComment": ["/*", "*/"] + }, + "brackets": [ + ["{", "}"], + ["[", "]"], + ["(", ")"] + ], + "autoClosingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "\"", "close": "\"" }, + { "open": "'", "close": "'" } + ], + "surroundingPairs": [ + { "open": "{", "close": "}" }, + { "open": "[", "close": "]" }, + { "open": "(", "close": ")" }, + { "open": "\"", "close": "\"" }, + { "open": "'", "close": "'" } + ], + "indentationRules": { + "increaseIndentPattern": ".*\\{[^}\"']*$", + "decreaseIndentPattern": "^\\s*\\}" + }, + "folding": { + "markers": { + "start": "^\\s*//\\s*#region\\b", + "end": "^\\s*//\\s*#endregion\\b" + } + }, + "wordPattern": "[a-zA-Z_][a-zA-Z0-9_]*", + "onEnterRules": [ + { + "beforeText": "^(\\s*(?:if|while|for|func|else|switch|case|default).*\\{)[^}]*$", + "action": { + "indent": "indent", + "appendText": "" + } + }, + { + "beforeText": "^\\s*\\}", + "action": { + "indent": "indent", + "appendText": "" + } + }, + { + "beforeText": "^#!(anko|blazium-anko)", + "action": { + "indent": "none" + } + } + ] + +} diff --git a/anko/package.json b/anko/package.json new file mode 100644 index 0000000..4ded35f --- /dev/null +++ b/anko/package.json @@ -0,0 +1,36 @@ +{ + "name": "anko", + "displayName": "Blazium Anko", + "description": "Syntax highlighting for Blazium\u0027s Flavor of Anko", + "publisher": "blazium-engine", + "version": "0.0.2", + "engines": { + "vscode": "^1.92.0" + }, + "categories": [ + "Programming Languages" + ], + "contributes": { + "languages": [ + { + "id": "blazium-anko", + "aliases": [ + "Blazium Anko", + "blazium-anko" + ], + "extensions": [ + ".anko", + ".blazium-anko" + ], + "configuration": "./language-configuration.json" + } + ], + "grammars": [ + { + "language": "blazium-anko", + "scopeName": "source.anko", + "path": "./syntaxes/blazium-anko.tmLanguage.json" + } + ] + } +} diff --git a/anko/syntaxes/blazium-anko.tmLanguage.json b/anko/syntaxes/blazium-anko.tmLanguage.json new file mode 100644 index 0000000..60aa50b --- /dev/null +++ b/anko/syntaxes/blazium-anko.tmLanguage.json @@ -0,0 +1,97 @@ +{ + "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json", + "name": "Blazium Anko", + "patterns": [ + { + "include": "#keywords" + }, + { + "include": "#strings" + }, + { + "include": "#variables" + }, + { + "include": "#parentheses" + }, + { + "include": "#functions" + }, + { + "include": "#comments" + }, + { + "include": "#shebang" + } + ], + "repository": { + "keywords": { + "patterns": [ + { + "name": "keyword.control.blazium-anko", + "match": "\\b(if|while|for|return|func)\\b" + } + ] + }, + "strings": { + "name": "string.quoted.double.blazium-anko", + "begin": "\"", + "end": "\"", + "patterns": [ + { + "name": "constant.character.escape.blazium-anko", + "match": "\\\\." + } + ] + }, + "variables": { + "patterns": [ + { + "name": "variable.other.blazium-anko", + "match": "\\b[a-zA-Z_][a-zA-Z0-9_]*\\b" + } + ] + }, + "parentheses": { + "patterns": [ + { + "name": "punctuation.definition.parentheses.blazium-anko", + "match": "[\\(\\)]" + } + ] + }, + "functions": { + "patterns": [ + { + "name": "entity.name.function.blazium-anko", + "match": "\\b(func)\\s+[a-zA-Z_][a-zA-Z0-9_]*" + } + ] + }, + "comments": { + "patterns": [ + { + "name": "comment.line.double-slash.blazium-anko", + "begin": "//", + "end": "(?=\\n)", + "patterns": [] + }, + { + "name": "comment.block.blazium-anko", + "begin": "/\\*", + "end": "\\*/", + "patterns": [] + } + ] + }, + "shebang": { + "patterns": [ + { + "name": "comment.line.shebang.blazium-anko", + "match": "^#!anko|^#!blazium-anko" + } + ] + } + }, + "scopeName": "source.anko" +} diff --git a/anko/vsc-extension-quickstart.md b/anko/vsc-extension-quickstart.md new file mode 100644 index 0000000..13b0657 --- /dev/null +++ b/anko/vsc-extension-quickstart.md @@ -0,0 +1,29 @@ +# Welcome to your VS Code Extension + +## What's in the folder + +* This folder contains all of the files necessary for your extension. +* `package.json` - this is the manifest file in which you declare your language support and define the location of the grammar file that has been copied into your extension. +* `syntaxes/blazium-anko.tmLanguage.json` - this is the Text mate grammar file that is used for tokenization. +* `language-configuration.json` - this is the language configuration, defining the tokens that are used for comments and brackets. + +## Get up and running straight away + +* Make sure the language configuration settings in `language-configuration.json` are accurate. +* Press `F5` to open a new window with your extension loaded. +* Create a new file with a file name suffix matching your language. +* Verify that syntax highlighting works and that the language configuration settings are working. + +## Make changes + +* You can relaunch the extension from the debug toolbar after making changes to the files listed above. +* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. + +## Add more language features + +* To add features such as IntelliSense, hovers and validators check out the VS Code extenders documentation at https://code.visualstudio.com/docs + +## Install your extension + +* To start using your extension with Visual Studio Code copy it into the `/.vscode/extensions` folder and restart Code. +* To share your extension with the world, read on https://code.visualstudio.com/docs about publishing an extension. diff --git a/dist/.keep b/dist/.keep new file mode 100644 index 0000000..e69de29 diff --git a/examples/script.anko b/examples/script.anko new file mode 100644 index 0000000..253e049 --- /dev/null +++ b/examples/script.anko @@ -0,0 +1,104 @@ +#!anko + +// Importing standard libraries +fmt = import("fmt") // For printing to the console +rand = import("math/rand") // For random number generation + +// Function: Demonstrates function definition +func example_function() { + // Variables: Demonstrates variable declaration and assignment + greeting = "Hello, World!" // String variable + number = 42 // Integer variable + pi = 3.14 // Float variable + isAnkoFun = true // Boolean variable + + fmt.Println(greeting) // Print a string + fmt.Println("The answer is:", number) // Print multiple values + fmt.Println("Value of pi:", pi) + fmt.Println("Is Anko fun?", isAnkoFun) +} + +// Arrays: Demonstrates array usage +func example_array() { + colors = ["Red", "Green", "Blue"] // Array of strings + for color in colors { // Looping through an array + fmt.Println("Color:", color) + } +} + +// Maps: Demonstrates map usage +func example_map() { + scores = { "Alice": 90, "Bob": 85 } // Map with string keys and integer values + fmt.Println("Alice's score:", scores["Alice"]) + + scores["Charlie"] = 95 // Adding a new key-value pair + for name, score in scores { // Iterating over a map + fmt.Println(name, "scored", score) + } +} + +// Conditionals: Demonstrates if-else statements +func example_conditionals(number) { + if number > 0 { + fmt.Println("The number is positive.") + } else if number < 0 { + fmt.Println("The number is negative.") + } else { + fmt.Println("The number is zero.") + } +} + +// Loops: Demonstrates for loops +func example_loops() { + for i = 1; i <= 5; i++ { // Simple for loop + fmt.Println("Number:", i) + } + + // While loop using a for construct + counter = 0 + for counter < 3 { + fmt.Println("Counter:", counter) + counter += 1 + } +} + +// Random Numbers: Demonstrates usage of the math/rand library +func example_random() { + rand.Seed(42) // Seeding the random number generator + randomNum = rand.Intn(100) // Random number between 0 and 99 + fmt.Println("Random number:", randomNum) +} + +// Functions with parameters and return values +func add_numbers(a, b) { + return a + b // Return the sum of two numbers +} + +// Example of calling all the structures +func main() { + fmt.Println("=== Variables ===") + example_function() + + fmt.Println("=== Arrays ===") + example_array() + + fmt.Println("=== Maps ===") + example_map() + + fmt.Println("=== Conditionals ===") + example_conditionals(5) + example_conditionals(0) + + fmt.Println("=== Loops ===") + example_loops() + + fmt.Println("=== Random Numbers ===") + example_random() + + fmt.Println("=== Function with Return ===") + result = add_numbers(10, 20) + fmt.Println("Sum of 10 and 20 is:", result) +} + +// Call the main function +main() diff --git a/scripts/update.ps1 b/scripts/update.ps1 new file mode 100644 index 0000000..1f9fc34 --- /dev/null +++ b/scripts/update.ps1 @@ -0,0 +1,60 @@ +# Requires PowerShell 5.0+ +param ( + [Parameter(Mandatory=$true)] + [ValidateSet("major", "minor", "patch")] + [string]$VersionType +) + +# Path to package.json +$PackageJsonPath = "./anko/package.json" + +# Check if package.json exists +if (-Not (Test-Path -Path $PackageJsonPath)) { + Write-Error "package.json not found at path: $PackageJsonPath" + exit 1 +} + +# Read package.json +$PackageData = Get-Content -Path $PackageJsonPath -Raw | ConvertFrom-Json + +# Ensure version field exists +if (-Not $PackageData.version) { + Write-Error "No version field found in package.json" + exit 1 +} + +# Parse version into major, minor, and patch +$VersionParts = $PackageData.version -split '\.' +if ($VersionParts.Count -ne 3) { + Write-Error "Invalid version format in package.json. Expected format: major.minor.patch" + exit 1 +} + +[int]$Major = $VersionParts[0] +[int]$Minor = $VersionParts[1] +[int]$Patch = $VersionParts[2] + +# Increment version based on input +switch ($VersionType) { + "major" { + $Major++ + $Minor = 0 + $Patch = 0 + } + "minor" { + $Minor++ + $Patch = 0 + } + "patch" { + $Patch++ + } +} + +# Update the version field +$PackageData.version = "$Major.$Minor.$Patch" + +# Write updated package.json back to file +$PackageData | ConvertTo-Json -Depth 10 | Set-Content -Path $PackageJsonPath + +# Output the new version +Write-Output $PackageData.version