diff --git a/.gitignore b/.gitignore index ab6b7b7c0..e9016baf0 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,6 @@ Output/ .idea/ .vscode/ + +# VSCode extension package +*.vsix diff --git a/glu-lang-syntax/.vscodeignore b/glu-lang-syntax/.vscodeignore new file mode 100644 index 000000000..9002eef29 --- /dev/null +++ b/glu-lang-syntax/.vscodeignore @@ -0,0 +1,3 @@ +.gitignore +*.vsix +test-syntax.glu diff --git a/glu-lang-syntax/CHANGELOG.md b/glu-lang-syntax/CHANGELOG.md new file mode 100644 index 000000000..1288d97e1 --- /dev/null +++ b/glu-lang-syntax/CHANGELOG.md @@ -0,0 +1,129 @@ +# Changelog + +All notable changes to the Glu Language Support extension will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.0] - 2025-10-16 + +### Added + +#### Syntax Highlighting +- Complete keyword support from Glu compiler's TokenKind.def + - Control flow: `if`, `else`, `while`, `for`, `return`, `break`, `continue`, `in` + - Declarations: `func`, `struct`, `union`, `enum`, `typealias`, `let`, `var` + - Module system: `import`, `public`, `private` + - Type modifiers: `unique`, `shared` + - Type casting: `as` + - Literals: `true`, `false`, `null` + +- Comprehensive type highlighting + - Signed integers: `Int`, `Int8`, `Int16`, `Int32`, `Int64` + - Unsigned integers: `UInt8`, `UInt16`, `UInt32`, `UInt64` + - Floating point: `Float16`, `Float32`, `Float64` + - Other primitives: `Char`, `String`, `Bool`, `Void` + - User-defined types (uppercase identifiers) + +- Complete operator support + - Arithmetic: `+`, `-`, `*`, `/`, `%` + - Comparison: `==`, `!=`, `<`, `<=`, `>`, `>=` + - Logical: `&&`, `||`, `!` + - Bitwise: `&`, `|`, `^`, `~`, `<<`, `>>` + - Range: `...`, `..<` + - Pointer: `.*` + - Scope: `::`, `::<` + - Arrow: `->` + - Assignment: `=` + - Ternary: `?` + +- Literal support + - Decimal, hexadecimal (0x), binary (0b), and octal (0o) integers + - Floating point with scientific notation + - Underscore separators in numbers + - String literals with escape sequences + - Character literals with escape sequences + - Boolean literals + +- Comment support + - Line comments (`//`) + - Block comments (`/* */`) + - Nested block comments + +- Attribute support + - Pattern matching for attributes like `@inline`, `@no_mangling`, etc. + +- Preprocessor directive support + - `#define`, `#undef`, `#include` + - Conditional compilation: `#if`, `#ifdef`, `#ifndef`, `#else`, `#elif`, `#endif` + - Multi-line macro support with backslash continuation + +- Function call highlighting + - Distinguishes function calls from other identifiers + +#### Language Configuration +- Auto-closing pairs for brackets, parentheses, and quotes +- Bracket matching +- Comment toggling support +- Word pattern for better word selection + +#### Documentation +- Comprehensive README.md with installation instructions +- INSTALL.md with detailed installation guide and troubleshooting +- FEATURES.md describing all syntax highlighting capabilities +- CHANGELOG.md for version tracking +- test-syntax.glu example file demonstrating all language features + +#### Build System +- .vscodeignore file to exclude unnecessary files from package +- LICENSE symlink to main repository license +- Updated package.json with proper metadata + +### Changed +- Updated package.json version from 0.0.1 to 0.1.0 +- Renamed RADME.md to README.md (typo fix) +- Improved package.json with repository, license, and keywords metadata +- Enhanced .gitignore to exclude .vsix files + +### Removed +- Old glu-syntax-0.0.1.vsix package (replaced with 0.1.0) + +## [0.0.1] - Initial Release + +### Added +- Basic syntax highlighting for Glu language +- Basic keyword support +- Basic type support +- Basic operator support +- Simple string and number literal support +- Line and block comment support +- Basic language configuration + +--- + +## Planned for Future Releases + +### [0.2.0] - Planned +- Code snippets for common Glu patterns +- Improved scope detection +- Better support for generic syntax +- Folding regions for functions and structures + +### [0.3.0] - Planned +- Language server protocol (LSP) support +- IntelliSense and code completion +- Go to definition +- Find all references +- Hover information + +### [0.4.0] - Planned +- Debugger support +- Build task integration +- Error diagnostics +- Symbol outline view + +### [1.0.0] - Planned +- Stable release with all core features +- Full language server support +- Comprehensive documentation +- Performance optimizations diff --git a/glu-lang-syntax/FEATURES.md b/glu-lang-syntax/FEATURES.md new file mode 100644 index 000000000..c16429b9d --- /dev/null +++ b/glu-lang-syntax/FEATURES.md @@ -0,0 +1,294 @@ +# Glu VSCode Extension Features + +This document describes all the syntax highlighting features provided by the Glu Language Support extension for Visual Studio Code. + +## Supported Language Features + +### 1. Keywords + +#### Control Flow Keywords +- `if`, `else` - Conditional statements +- `while`, `for` - Loop statements +- `return` - Return from function +- `break`, `continue` - Loop control +- `in` - For-in loop syntax + +#### Declaration Keywords +- `func` - Function declaration +- `struct` - Structure type declaration +- `union` - Union type declaration +- `enum` - Enumeration type declaration +- `typealias` - Type alias declaration +- `let` - Immutable variable declaration +- `var` - Mutable variable declaration + +#### Module Keywords +- `import` - Import module or symbol +- `public` - Public visibility modifier +- `private` - Private visibility modifier + +#### Type Keywords +- `unique` - Unique pointer type +- `shared` - Shared pointer type +- `as` - Type cast operator + +#### Literal Keywords +- `true`, `false` - Boolean literals +- `null` - Null pointer literal + +### 2. Primitive Types + +The extension highlights all built-in Glu types: + +#### Integer Types +- `Int`, `Int8`, `Int16`, `Int32`, `Int64` - Signed integers +- `UInt8`, `UInt16`, `UInt32`, `UInt64` - Unsigned integers + +#### Floating Point Types +- `Float16`, `Float32`, `Float64` - Floating point numbers + +#### Other Primitive Types +- `Char` - Character type +- `String` - String type +- `Bool` - Boolean type +- `Void` - Void type (no return value) + +#### User-Defined Types +The extension automatically highlights any identifier starting with an uppercase letter as a type (e.g., `Point`, `Color`, `MyStruct`). + +### 3. Operators + +#### Arithmetic Operators +- `+`, `-`, `*`, `/`, `%` - Basic arithmetic +- Unary `+`, `-` - Positive/negative + +#### Comparison Operators +- `==`, `!=` - Equality comparison +- `<`, `<=`, `>`, `>=` - Relational comparison + +#### Logical Operators +- `&&` - Logical AND +- `||` - Logical OR +- `!` - Logical NOT + +#### Bitwise Operators +- `&` - Bitwise AND +- `|` - Bitwise OR +- `^` - Bitwise XOR +- `~` - Bitwise NOT (complement) +- `<<` - Left shift +- `>>` - Right shift + +#### Range Operators +- `...` - Inclusive range (e.g., `0...10`) +- `..<` - Exclusive range (e.g., `0..<10`) + +#### Pointer Operators +- `.*` - Pointer dereference + +#### Other Operators +- `=` - Assignment +- `->` - Function return type +- `::` - Scope resolution +- `::<` - Generic scope resolution +- `.` - Member access +- `?` - Ternary operator + +#### Punctuation +- `,` - Comma separator +- `;` - Statement terminator +- `:` - Type annotation + +### 4. Literals + +#### Integer Literals +```glu +42 // Decimal +0xFF // Hexadecimal +0b1010 // Binary +0o755 // Octal +1_000_000 // Underscore separators +``` + +#### Floating Point Literals +```glu +3.14 // Basic float +1.5e-10 // Scientific notation (lowercase) +2.0E+5 // Scientific notation (uppercase) +3_141.592_653 // Underscore separators +``` + +#### String Literals +```glu +"Hello, World!" // Basic string +"Line 1\nLine 2" // Escape sequences +"Quote: \"test\"" // Escaped quotes +``` + +#### Character Literals +```glu +'A' // Basic character +'\n' // Escape sequence +'\t' // Tab character +``` + +#### Boolean Literals +```glu +true +false +``` + +#### Null Literal +```glu +null +``` + +### 5. Comments + +#### Line Comments +```glu +// This is a single-line comment +``` + +#### Block Comments +```glu +/* This is a + multi-line + block comment */ +``` + +#### Nested Block Comments +```glu +/* Outer comment + /* Nested comment */ + Still outer comment */ +``` + +### 6. Attributes + +Attributes are special annotations that modify declarations: + +```glu +@inline // Inline function hint +@no_mangling // Disable name mangling +@deprecated // Mark as deprecated +``` + +Attributes are highlighted with the `@` symbol and can be placed before declarations. + +### 7. Preprocessor Directives + +The extension supports C-style preprocessor directives: + +```glu +#define MAX_SIZE 100 +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#include "header.glu" +#ifdef DEBUG +#ifndef RELEASE +#else +#elif +#endif +#undef +``` + +Multi-line macros using backslash continuation are also supported: + +```glu +#define MACRO(x) \ + statement1; \ + statement2; +``` + +### 8. Functions + +#### Function Declarations +```glu +func functionName(param: Type) -> ReturnType { + // body +} +``` + +#### Function Calls +```glu +functionName(argument) +``` + +Function names in calls are highlighted distinctly from keywords and variables. + +### 9. Advanced Features + +#### Type Annotations +```glu +let variable: Int = 10; +var mutable: String = "hello"; +``` + +#### Generic Syntax +```glu +array::::create(10) +``` + +#### Pointer Types +```glu +func process(ptr: *Int) -> Void { + let value = .*ptr; +} +``` + +#### Member Access +```glu +struct.field +object.method() +``` + +#### Range-Based Loops +```glu +for i in 0...10 { + printLine(i); +} + +for i in 0..<10 { + printLine(i); +} +``` + +## Color Scheme + +The extension uses semantic token types that work with all VSCode themes. The typical color mapping is: + +- **Keywords**: Purple/Magenta +- **Types**: Green/Cyan +- **Strings**: Orange/Red +- **Numbers**: Light Green +- **Comments**: Gray/Muted +- **Functions**: Yellow +- **Operators**: White/Default +- **Attributes**: Yellow/Orange +- **Preprocessor**: Purple/Magenta + +Note: Actual colors depend on your selected VSCode theme. + +## Language Configuration + +The extension also provides: + +- **Auto-closing pairs**: Automatically closes `{}`, `[]`, `()`, `""`, `''` +- **Bracket matching**: Highlights matching brackets +- **Comment toggling**: Use `Ctrl+/` to toggle line comments +- **Block comment toggling**: Use `Shift+Alt+A` to toggle block comments + +## Limitations + +- The extension provides syntax highlighting only, not semantic analysis +- IntelliSense, code completion, and error checking are not included +- Jump-to-definition and other language server features are not available + +## Future Enhancements + +Potential future additions: +- Code snippets for common Glu patterns +- Language server support for IntelliSense +- Debugger integration +- Build task integration +- Symbol outline support diff --git a/glu-lang-syntax/INSTALL.md b/glu-lang-syntax/INSTALL.md new file mode 100644 index 000000000..3789662bf --- /dev/null +++ b/glu-lang-syntax/INSTALL.md @@ -0,0 +1,171 @@ +# Installation Guide for Glu VSCode Extension + +This guide provides detailed instructions for installing and using the Glu language support extension for Visual Studio Code. + +## Prerequisites + +- Visual Studio Code version 1.85.0 or higher +- (Optional) Node.js and npm for building from source + +## Installation Methods + +### Method 1: Install Pre-built Extension (Recommended) + +1. **Download the Extension** + + Download the latest `glu-syntax-0.1.0.vsix` file from the `glu-lang-syntax` directory of the repository. + +2. **Install via VSCode GUI** + + a. Open Visual Studio Code + + b. Go to the Extensions view by clicking the Extensions icon in the Activity Bar or pressing `Ctrl+Shift+X` (Windows/Linux) or `Cmd+Shift+X` (macOS) + + c. Click on the `...` (More Actions) button at the top of the Extensions view + + d. Select "Install from VSIX..." + + e. Navigate to and select the downloaded `glu-syntax-0.1.0.vsix` file + + f. Click "Install" + +3. **Install via Command Line** + + ```bash + code --install-extension /path/to/glu-syntax-0.1.0.vsix + ``` + +4. **Verify Installation** + + - Open a `.glu` file in VSCode + - The language mode in the bottom-right corner should show "Glu" + - Syntax highlighting should be applied automatically + +### Method 2: Build and Install from Source + +If you want to build the extension from source or make modifications: + +1. **Install Dependencies** + + ```bash + npm install -g @vscode/vsce + ``` + +2. **Navigate to Extension Directory** + + ```bash + cd /path/to/glu/glu-lang-syntax + ``` + +3. **Package the Extension** + + ```bash + vsce package + ``` + + Or using npx (no installation required): + + ```bash + npx @vscode/vsce package + ``` + + This will create a `glu-syntax-0.1.0.vsix` file in the current directory. + +4. **Install the Extension** + + ```bash + code --install-extension glu-syntax-0.1.0.vsix + ``` + +## Testing the Extension + +1. **Open a Glu File** + + Create or open a file with the `.glu` extension. + +2. **Verify Syntax Highlighting** + + The following should be highlighted: + + - **Keywords**: `func`, `struct`, `enum`, `if`, `else`, `while`, `for`, `return`, etc. + - **Types**: `Int`, `String`, `Bool`, `Float32`, custom types + - **Attributes**: `@inline`, `@no_mangling` + - **Operators**: `+`, `-`, `*`, `/`, `==`, `!=`, `&&`, `||`, etc. + - **Literals**: Numbers, strings, booleans + - **Comments**: `//` and `/* */` + - **Preprocessor**: `#define`, `#include` + +3. **Test Language Features** + + - Try typing `//` and verify comment highlighting + - Type `func` and verify keyword highlighting + - Try auto-closing pairs: `{`, `[`, `(` + +## Troubleshooting + +### Extension Not Activated + +If the extension doesn't activate: + +1. Check that the file extension is `.glu` +2. Reload VSCode: Press `Ctrl+Shift+P` (Windows/Linux) or `Cmd+Shift+P` (macOS), type "Reload Window", and press Enter +3. Check the Extension view to ensure the extension is enabled + +### No Syntax Highlighting + +1. Verify the language mode in the bottom-right corner shows "Glu" +2. Manually select the language: Click the language mode indicator and select "Glu" +3. Try reinstalling the extension + +### Colors Look Wrong + +Syntax highlighting colors are controlled by your VSCode theme. Try different themes to see which works best: + +1. Press `Ctrl+K Ctrl+T` (Windows/Linux) or `Cmd+K Cmd+T` (macOS) +2. Select a different color theme + +Recommended themes for Glu: +- Dark+ +- Monokai +- One Dark Pro + +## Uninstalling + +To uninstall the extension: + +1. Go to the Extensions view (`Ctrl+Shift+X` / `Cmd+Shift+X`) +2. Find "Glu Language Support" in the list +3. Click the gear icon and select "Uninstall" + +Or via command line: + +```bash +code --uninstall-extension glu-lang.glu-syntax +``` + +## Development and Contributing + +To develop or contribute to the extension: + +1. Clone the Glu repository +2. Navigate to `glu-lang-syntax` directory +3. Make your changes to: + - `glu.tmLanguage.json` - Syntax highlighting rules + - `language-configuration.json` - Language configuration + - `package.json` - Extension metadata +4. Test your changes by packaging and installing the extension +5. Submit a pull request to the Glu repository + +## Additional Resources + +- [Glu Language Website](https://glu-lang.org/) +- [Glu Documentation](https://glu-lang.org/reference/) +- [VSCode Extension API](https://code.visualstudio.com/api) +- [TextMate Grammar Guide](https://macromates.com/manual/en/language_grammars) + +## Support + +For issues or questions: + +- [GitHub Issues](https://github.com/glu-lang/glu/issues) +- [Glu Community](https://glu-lang.org/) diff --git a/glu-lang-syntax/LICENSE b/glu-lang-syntax/LICENSE new file mode 120000 index 000000000..ea5b60640 --- /dev/null +++ b/glu-lang-syntax/LICENSE @@ -0,0 +1 @@ +../LICENSE \ No newline at end of file diff --git a/glu-lang-syntax/QUICK_START.md b/glu-lang-syntax/QUICK_START.md new file mode 100644 index 000000000..5acf2073d --- /dev/null +++ b/glu-lang-syntax/QUICK_START.md @@ -0,0 +1,95 @@ +# Quick Start Guide + +Get started with the Glu VSCode extension in 3 simple steps! + +## Step 1: Install the Extension + +### Option A: Via Command Line (Fastest) +```bash +code --install-extension glu-syntax-0.1.0.vsix +``` + +### Option B: Via VSCode GUI +1. Open VSCode +2. Press `Ctrl+Shift+X` (Windows/Linux) or `Cmd+Shift+X` (macOS) +3. Click the `...` menu at the top +4. Select "Install from VSIX..." +5. Choose `glu-syntax-0.1.0.vsix` + +## Step 2: Open a Glu File + +Create a new file with `.glu` extension or open an existing one: + +```bash +touch hello.glu +code hello.glu +``` + +## Step 3: Start Coding! + +Try this example: + +```glu +// Simple Glu program +import io::printLine; + +@inline +func greet(name: String) -> Void { + printLine("Hello, " + name + "!"); +} + +func main() -> Int { + let name = "World"; + greet(name); + return 0; +} +``` + +You should see: +- ✨ Keywords highlighted (`func`, `let`, `return`) +- 🎨 Types colored (`String`, `Int`, `Void`) +- 💬 Comments in muted colors +- 🔧 Functions and attributes clearly visible + +## What's Next? + +- 📖 Read [FEATURES.md](FEATURES.md) to see all supported language features +- 🔧 Check [INSTALL.md](INSTALL.md) if you encounter any issues +- 💡 Look at [test-syntax.glu](test-syntax.glu) for more examples + +## Common Tasks + +### Toggle Line Comment +- Windows/Linux: `Ctrl+/` +- macOS: `Cmd+/` + +### Toggle Block Comment +- Windows/Linux: `Shift+Alt+A` +- macOS: `Shift+Option+A` + +### Change Color Theme +1. Press `Ctrl+K Ctrl+T` (Windows/Linux) or `Cmd+K Cmd+T` (macOS) +2. Select your preferred theme + +Recommended themes: Dark+, Monokai, One Dark Pro + +## Troubleshooting + +### Extension Not Working? +1. Check the language mode shows "Glu" (bottom-right corner) +2. If not, click it and select "Glu" from the list +3. Reload window: `Ctrl+Shift+P` → "Reload Window" + +### Need More Help? +See the full [INSTALL.md](INSTALL.md) guide for detailed troubleshooting. + +## Resources + +- 🌐 [Glu Website](https://glu-lang.org/) +- 📚 [Glu Documentation](https://glu-lang.org/reference/) +- 📖 [The Glu Book](https://glu-lang.org/theBook/) +- 🐛 [Report Issues](https://github.com/glu-lang/glu/issues) + +--- + +**Happy Coding with Glu! 🚀** diff --git a/glu-lang-syntax/RADME.md b/glu-lang-syntax/RADME.md deleted file mode 100644 index 7633cd675..000000000 --- a/glu-lang-syntax/RADME.md +++ /dev/null @@ -1,3 +0,0 @@ -brew install vsce -vsce package && code --install-extension glu-syntax-0.0.1.vsix -Reopen Vscode to see changes. \ No newline at end of file diff --git a/glu-lang-syntax/README.md b/glu-lang-syntax/README.md new file mode 100644 index 000000000..07b71bf1e --- /dev/null +++ b/glu-lang-syntax/README.md @@ -0,0 +1,64 @@ +# Glu Language Support for Visual Studio Code + +This extension provides syntax highlighting and language support for the [Glu programming language](https://glu-lang.org/). + +## Features + +- **Syntax Highlighting**: Full syntax highlighting for Glu language constructs including: + - Keywords (if, else, while, for, return, etc.) + - Types (Int, String, Bool, custom types, etc.) + - Functions and function calls + - Operators (arithmetic, logical, bitwise, comparison, etc.) + - Literals (numbers, strings, booleans) + - Comments (line and block) + - Attributes (@inline, @no_mangling, etc.) + - Preprocessor directives (#define, #include, etc.) + +- **Language Configuration**: Auto-closing pairs, bracket matching, and comment toggling + +## Installation + +### From VSIX File + +1. Download the latest `.vsix` file from the releases +2. Open Visual Studio Code +3. Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X) +4. Click on the `...` menu and select "Install from VSIX..." +5. Select the downloaded `.vsix` file + +### From Command Line + +```bash +code --install-extension glu-syntax-0.1.0.vsix +``` + +## Building from Source + +To build the extension from source: + +1. Install `vsce` (Visual Studio Code Extension Manager): + ```bash + npm install -g @vscode/vsce + ``` + +2. Package the extension: + ```bash + vsce package + ``` + +3. Install the generated `.vsix` file: + ```bash + code --install-extension glu-syntax-0.1.0.vsix + ``` + +## About Glu + +Glu is a modern systems programming language designed as a "glue" language for connecting and interoperating with other languages and systems via LLVM. Learn more at [glu-lang.org](https://glu-lang.org/). + +## Contributing + +Contributions are welcome! Please see the main [Glu repository](https://github.com/glu-lang/glu) for contribution guidelines. + +## License + +This extension is distributed under the Apache License 2.0. See the [LICENSE](../LICENSE) file for more details. \ No newline at end of file diff --git a/glu-lang-syntax/glu-syntax-0.0.1.vsix b/glu-lang-syntax/glu-syntax-0.0.1.vsix deleted file mode 100644 index f1332a4d3..000000000 Binary files a/glu-lang-syntax/glu-syntax-0.0.1.vsix and /dev/null differ diff --git a/glu-lang-syntax/glu.tmLanguage.json b/glu-lang-syntax/glu.tmLanguage.json index 2c655f7ce..7684dd9b2 100644 --- a/glu-lang-syntax/glu.tmLanguage.json +++ b/glu-lang-syntax/glu.tmLanguage.json @@ -2,7 +2,9 @@ "name": "Glu", "scopeName": "source.glu", "patterns": [ + { "include": "#preprocessor" }, { "include": "#comments" }, + { "include": "#attributes" }, { "include": "#strings" }, { "include": "#numbers" }, { "include": "#keywords" }, @@ -12,6 +14,36 @@ { "include": "#identifiers" } ], "repository": { + "preprocessor": { + "patterns": [ + { + "name": "meta.preprocessor.glu", + "begin": "^\\s*#\\s*(define|undef|if|ifdef|ifndef|else|elif|endif|include)", + "end": "(?=|<|>|=|\\+=|\\-=|\\*=|\\/=|%=|&&|\\|\\||!|\\?|:|\\.|,)" + "name": "keyword.operator.comparison.glu", + "match": "==|!=|<=|>=|<|>" + }, + { + "name": "keyword.operator.logical.glu", + "match": "&&|\\|\\||!" + }, + { + "name": "keyword.operator.bitwise.glu", + "match": "&|\\||\\^|~|<<|>>" + }, + { + "name": "keyword.operator.arithmetic.glu", + "match": "\\+|-|\\*|/|%" + }, + { + "name": "keyword.operator.range.glu", + "match": "\\.\\.\\.|\\.\\.<" + }, + { + "name": "keyword.operator.pointer.glu", + "match": "\\.\\*" + }, + { + "name": "keyword.operator.assignment.glu", + "match": "=" + }, + { + "name": "keyword.operator.scope.glu", + "match": "::|::<" + }, + { + "name": "keyword.operator.arrow.glu", + "match": "->" + }, + { + "name": "punctuation.accessor.glu", + "match": "\\." + }, + { + "name": "punctuation.separator.glu", + "match": ",|;|:" + }, + { + "name": "keyword.operator.ternary.glu", + "match": "\\?" } ] }, - "identifiers": { + "types": { "patterns": [ { - "name": "variable.other.glu", - "match": "\\b[A-Za-z_][A-Za-z0-9_]*\\b" + "name": "support.type.primitive.glu", + "match": "\\b(?:Int|Int8|Int16|Int32|Int64|UInt8|UInt16|UInt32|UInt64|Float16|Float32|Float64|Char|String|Bool|Void)\\b" + }, + { + "name": "entity.name.type.glu", + "match": "\\b[A-Z][A-Za-z0-9_]*\\b" } ] }, - "types": { + "identifiers": { "patterns": [ { - "name": "support.type.primitive.glu", - "match": "\\b(?:Int|Char|String|Bool|Void)\\b" + "name": "variable.other.glu", + "match": "\\b[a-z_][A-Za-z0-9_]*\\b" } ] } diff --git a/glu-lang-syntax/package.json b/glu-lang-syntax/package.json index afb2699a9..007aa43e2 100644 --- a/glu-lang-syntax/package.json +++ b/glu-lang-syntax/package.json @@ -1,15 +1,26 @@ { "name": "glu-syntax", - "displayName": "Glu Syntax Highlighting", - "description": "Syntax highlighting support for Glu language", - "version": "0.0.1", - "publisher": "yourname", + "displayName": "Glu Language Support", + "description": "Syntax highlighting and language support for the Glu programming language", + "version": "0.1.0", + "publisher": "glu-lang", + "repository": { + "type": "git", + "url": "https://github.com/glu-lang/glu" + }, + "license": "Apache-2.0", "engines": { "vscode": "^1.85.0" }, "categories": [ "Programming Languages" ], + "keywords": [ + "glu", + "syntax", + "highlighting", + "llvm" + ], "contributes": { "languages": [ { diff --git a/glu-lang-syntax/test-syntax.glu b/glu-lang-syntax/test-syntax.glu new file mode 100644 index 000000000..eab8413a7 --- /dev/null +++ b/glu-lang-syntax/test-syntax.glu @@ -0,0 +1,164 @@ +// Test file for Glu syntax highlighting +/* Block comment + multiline +*/ + +#define MAX_SIZE 100 +#define MIN(a, b) ((a) < (b) ? (a) : (b)) + +import io::print; +import io::printLine; + +// Attributes +@inline +@no_mangling +public func factorial(n: Int) -> Int { + if (n <= 1) { + return 1; + } else { + return n * factorial(n - 1); + } +} + +// Struct definition +struct Point { + x: Float32, + y: Float32, +} + +// Enum definition +enum Color: Int { + Red, + Green = 2, + Blue, +} + +// Union definition +union Data { + intValue: Int, + floatValue: Float64, +} + +// Type alias +typealias IntPtr = *Int; + +// Function with various operators +private func testOperators() -> Void { + let a = 10; + let b = 20; + var result: Int; + + // Arithmetic operators + result = a + b; + result = a - b; + result = a * b; + result = a / b; + result = a % b; + + // Comparison operators + let eq = a == b; + let ne = a != b; + let lt = a < b; + let le = a <= b; + let gt = a > b; + let ge = a >= b; + + // Logical operators + let and = true && false; + let or = true || false; + let not = !true; + + // Bitwise operators + result = a & b; + result = a | b; + result = a ^ b; + result = ~a; + result = a << 2; + result = a >> 2; + + // Range operators + for i in 0...10 { + printLine(i); + } + + for i in 0..<10 { + printLine(i); + } +} + +// Types +func testTypes() -> Void { + let i8: Int8 = 127; + let i16: Int16 = 32767; + let i32: Int32 = 2147483647; + let i64: Int64 = 9223372036854775807; + + let u8: UInt8 = 255; + let u16: UInt16 = 65535; + let u32: UInt32 = 4294967295; + let u64: UInt64 = 18446744073709551615; + + let f16: Float16 = 3.14; + let f32: Float32 = 3.141592; + let f64: Float64 = 3.14159265358979; + + let c: Char = 'A'; + let s: String = "Hello, Glu!"; + let b: Bool = true; + let v: Void; + let n = null; +} + +// Literals +func testLiterals() -> Void { + // Integer literals + let decimal = 42; + let hex = 0xFF; + let binary = 0b1010; + let octal = 0o755; + let underscore = 1_000_000; + + // Float literals + let float1 = 3.14; + let float2 = 1.5e-10; + let float3 = 2.0E+5; + + // String literals + let str = "Hello, \"World\"!"; + let escaped = "Line 1\nLine 2\tTabbed"; + + // Character literals + let char = 'x'; + let escape_char = '\n'; + + // Boolean literals + let t = true; + let f = false; +} + +// Scope resolution +func testScope() -> Void { + let result = math::sqrt(16.0); + let generic = array::::create(10); +} + +// Pointers +func testPointers(ptr: *Int) -> Void { + let value = .*ptr; + let addr = &value; +} + +// Main function +func main() -> Int { + printLine("Testing Glu syntax highlighting!"); + + let fact = factorial(5); + printLine(fact); + + testOperators(); + testTypes(); + testLiterals(); + testScope(); + + return 0; +}