Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 45 additions & 31 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,34 +1,48 @@
# Generated by Cargo
# will have compiled files and executables
debug
target
```
# Dependencies
node_modules/

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# Generated by cargo mutants
# Contains mutation testing data
**/mutants.out*/

# RustRover
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# Editor/IDE files
.vscode/
.VSCodeCounter/
.trae/

lcov.info

# Generated by gtest
Testing/

*.disabled
*.old*
test.*

# Compiled/Binary files
*.pyc
*.class
*.o
*.exe
*.dll
*.so
*.a
*.obj
*.out

# Dependency directories
__pycache__/
.mypy_cache/
.pytest_cache/
target/
.gradle/

# Editor/IDE files
.idea/
*.swp
*.swo
*.tmp

# System/Environment files
.DS_Store
Thumbs.db
.env
.env.local
*.env.*

# Other common ignores
*.log
coverage/
htmlcov/
.coverage

# Build artifacts
dist/
build/
```
72 changes: 61 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,72 @@
# koicore
# KoiLang VSCode Extension

Core KoiLang language module providing basic language features.
This extension provides syntax highlighting for KoiLang files (.koi) in Visual Studio Code.

[![License](https://img.shields.io/github/license/Visecy/koicore.svg)](LICENSE)
[![Crates.io](https://img.shields.io/crates/v/koicore.svg)](https://crates.io/crates/koicore)
[![Documentation](https://docs.rs/koicore/badge.svg)](https://docs.rs/koicore)
## Features

- Syntax highlighting for KoiLang commands and arguments
- Support for various data types including strings, numbers, lists, and dictionaries
- Comment highlighting
- Text content highlighting

**English** | [中文](./README_cn.md)
## Supported Syntax

## Overview
### Commands
Commands start with `#` followed by a command name and optional arguments:

KoiLang is a markup language designed for narrative content, particularly suited for visual novels, interactive fiction, and dialogue-driven applications. The `koicore` crate provides the fundamental parsing and data structures needed to work with KoiLang files.
```
#character Alice "Hello, world!"
#background forest
```

The core idea of KoiLang is to separate data and instructions. KoiLang files contain the data (commands and text), while your application provides the instructions (how to handle those commands). This makes KoiLang files easy to read and write for humans, while being powerful enough for complex applications.
### Arguments
KoiLang supports various argument types:

## Features
- **Strings**: `"A string with content"`
- **Numbers**: `123`, `1.23`, `0b101`, `0x6CF`
- **Literals**: `identifier`, `__name__`
- **Named arguments**: `name(value)`
- **Lists**: `name(item1, item2, item3)`
- **Dictionaries**: `name(key1: value1, key2: value2)`

### Comments
Lines starting with `##` are treated as comments:

```
## This is a comment
```

### Text Content
Plain text without the `#` prefix is treated as content:

- **Streaming Parser**: Process files of any size with constant memory usage
```
This is regular text content.
It can span multiple lines.
```

## File Extension

This extension supports files with the `.koi` extension.

## Example

```
## Character definitions
#character Alice "Alice" color(255, 100, 100)
#character Bob "Bob" color(100, 255, 100)

## Background
#background forest

## Dialog
Alice "Hello, Bob!"
Bob "Hi, Alice! How are you today?"
Alice "I'm doing well, thank you for asking."

## Actions
#action walk pos(100, 200)
#draw Line 2 pos0(x: 0, y: 0) pos1(x: 16, y: 16) thickness(2) color(255, 255, 255)
```
- **Multiple Input Sources**: Parse from strings, files, or custom input sources
- **Encoding Support**: Handle various text encodings (UTF-8, GBK, etc.) through `DecodeBufReader`
- **Comprehensive Error Handling**: Detailed error messages with source locations and context
Expand Down
22 changes: 22 additions & 0 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"comments": {
"lineComment": "##"
},
"brackets": [
["{", "}"],
["[", "]"],
["(", ")"]
],
"autoClosingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""]
],
"surroundingPairs": [
["{", "}"],
["[", "]"],
["(", ")"],
["\"", "\""]
]
}
34 changes: 34 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "koilang",
"displayName": "KoiLang",
"description": "Syntax highlighting and language support for KoiLang",
"version": "0.0.1",
"engines": {
"vscode": "^1.74.0"
},
"categories": [
"Programming Languages"
],
"contributes": {
"languages": [
{
"id": "koilang",
"aliases": [
"KoiLang",
"koilang"
],
"extensions": [
".koi"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "koilang",
"scopeName": "source.koi",
"path": "./syntaxes/koilang.json"
}
]
}
}
Loading
Loading