Skip to content

Commit

Permalink
build: Release 0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielHauge committed Jul 29, 2024
1 parent 9fad4a9 commit af85225
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 20 deletions.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
[package]
name = "ebnf-lsp"
name = "ebnfer"
version = "0.1.0"
edition = "2021"
authors = ["Daniel <animcuil@gmail.com>"]
description = "A LSP implementation for EBNF."
readme = "README.md"
repository = "https://github.com/DanielHauge/ebnfer"
license = "MIT"


[dependencies]
nom = "7.1.3"
Expand Down
32 changes: 22 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
![Test](https://github.com/DanielHauge/ebnf-lsp/actions/workflows/rust.yml/badge.svg)

# EBNF Lsp
# EBNFER

An implementation of the language server protocol (LSP) for EBNF grammars.

## Features

- [x] Syntax error diagnostics
- [x] Hover information
- [x] Multi definitions handling
- [X] Semantic tokens (Root rule)
- [x] Diagnostics
- [x] Hover
- [x] References
- [x] Completion
- [X] Semantic tokens Root rule
- [x] Document formatting
- [x] Rename
- [x] Go to definition
- [x] Multi definition hover information
- [x] Document symbols
- [x] supress unused diagnostics rule
- [x] Code actions
- [ ] General document highlighting
- [x] Code actions (supress unused warning)

## Installation

Build from source or install via cargo:

## Roadmap features
```bash
cargo install ebnfer
```

## Further development

- [ ] Vs Code extension - w. general document highlighting
- [ ] Workspace support - multiple files

## Inspired

This project is inspired by the ebnf analysis crate on crates.io - [ebnf](https://github.com/RubixDev/ebnf).
Also inspired by the following youtube video: [Learn By Building: Language Server Protocol - TJ Devries](https://www.youtube.com/watch?v=YsdlcQoHqPY).
5 changes: 4 additions & 1 deletion src/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::{collections::HashMap, error::Error};

use ebnf_fmt::configuration::NewlineKind;
use lsp_types::notification::{self, DidOpenTextDocument, Notification};
use lsp_types::request::{
CodeActionRequest, Completion, DocumentDiagnosticRequest, DocumentSymbolRequest, Formatting,
Expand Down Expand Up @@ -103,6 +102,7 @@ pub fn start() -> Result<(), Box<dyn Error>> {
Ok(())
}

#[cfg(debug_assertions)]
fn log_file(msg: &str) {
use std::fs::OpenOptions;
use std::io::Write;
Expand All @@ -114,6 +114,9 @@ fn log_file(msg: &str) {
writeln!(file, "{}", msg).unwrap();
}

#[cfg(not(debug_assertions))]
fn log_file(_msg: &str) {}

// type alias: ctx = (HashMap<String, LspContext>, HashMap<String, Option<LspError>>)
struct LspContext {
lsp: HashMap<String, AnalysisContext>,
Expand Down
59 changes: 56 additions & 3 deletions test.ebnf
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
World = "World!";
Hello = "Hello";
Hello_There = Hello , ' ' , World;
Program = { Statement } ;
Statement = { Assignment
| IfStatement
| WhileStatement
| PrintStatement
| BlockStatement } ;
Assignment = Identifier
, '='
, ExpressionTwo
, ';' ;
IfStatement = 'if'
, ExpressionTwo
, BlockStatement
, [ 'else'
, BlockStatement ] ;
(* #[allow(unused)] *)
Unused = 'Hello' ;
WhileStatement = 'while'
, ExpressionTwo
, BlockStatement ;
PrintStatement = 'print'
, ExpressionTwo
, ';' ;
BlockStatement = '{'
, { Statement }
, '}' ;
Identifier = [ 'a' - 'z'
| 'A' - 'Z' ]
, { [ 'a' - 'z'
| 'A' - 'Z'
| '0' - '9' ] } ;
(* #[allow(unused)] *)
NotUsed = 'Hello' ;
ExpressionTwo = Term
| ExpressionTwo
, '+'
, Term ;
Term = Factor
| Term
, '*'
, Factor ;
Factor = Identifier
| Number
| '('
, ExpressionTwo
, ')' ;
Number = [ '0' - '9' ]
, { [ '0' - '9' ] } ;
5 changes: 0 additions & 5 deletions test2.ebnf

This file was deleted.

0 comments on commit af85225

Please sign in to comment.