Skip to content

Commit

Permalink
Merge pull request #145 from micksmix/master
Browse files Browse the repository at this point in the history
Updated grammar updater, wrote a README, added Swift grammar, updated Kotlin grammar to v0.3.1
  • Loading branch information
smacker committed Mar 20, 2024
2 parents 1f283e2 + b934799 commit a4b649a
Show file tree
Hide file tree
Showing 18 changed files with 1,083,653 additions and 522,185 deletions.
59 changes: 58 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,58 @@
.idea
.idea

# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,macos

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### macOS Patch ###
# iCloud generated files
*.icloud

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets

# Local History for Visual Studio Code
.history/

# Built Visual Studio Code Extensions
*.vsix

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,macos
62 changes: 62 additions & 0 deletions _automation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Grammar Version Checker

This Go program automates the process of checking and updating grammar versions for various programming languages. It targets specific grammars defined in a JSON configuration file and supports operations like checking for updates and performing updates.

## Features

- **Check for Updates**: Scan through defined grammars and check if there are new versions available.
- **Update Grammar**: Update a specific grammar to its latest version.
- **Update All**: Batch update all grammars to their latest versions.

## Prerequisites

- Go installed on your machine.
- Git installed and accessible from your command line.

## Configuration

The program relies on a JSON file (`_automation/grammars.json`) for the list of grammars to manage. Each grammar should specify its `language`, `url`, `files`, `reference` (tag or branch), and `revision` (commit hash).

Example structure of `grammars.json`:

```json
[
{
"language": "golang",
"url": "https://github.com/tree-sitter/tree-sitter-go",
"files": [
"parser.c"
],
"reference": "master",
"revision": "64457ea6b73ef5422ed1687178d4545c3e91334a",
"updatedBasedOn": "commit", //OPTIONAL: Use "tag" (instead of "commit") to restrict updates to the latest tag and not latest commit
}
]
```

`updatedBasedOn` is an OPTIONAL property. If not provided, updating from the latest commit will be presumed.

## Usage

### To Check for Updates

```bash
go run ./_automation/main.go check-updates
```

### To update a specific grammar
```bash
go run ./_automation/main.go update <language> [--force]
```

### To update all grammars
```bash
go run ./_automation/main.go update-all
```

## Test After Updating
Once you've updated a grammar, it is important to test that the binding tests still pass (`binding_test.go`). Then run:

```bash
go test -v ./...
```
Loading

0 comments on commit a4b649a

Please sign in to comment.