Unnamed repository; edit this file 'description' to name the repository.
Reformat
Lukas Wirth 5 months ago
parent ae4b7f6 · commit ee3c21f
-rw-r--r--Cargo.lock14
-rw-r--r--Cargo.toml4
-rw-r--r--lib/ungrammar/Cargo.toml2
-rw-r--r--lib/ungrammar/src/error.rs5
-rw-r--r--lib/ungrammar/src/parser.rs32
-rw-r--r--lib/ungrammar/ungrammar2json/src/main.rs1
6 files changed, 24 insertions, 34 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6f5db9e8fc..5bc4d9f3df 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3195,10 +3195,22 @@ checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94"
[[package]]
name = "ungrammar"
version = "1.16.1"
+
+[[package]]
+name = "ungrammar"
+version = "1.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3e5df347f0bf3ec1d670aad6ca5c6a1859cd9ea61d2113125794654ccced68f"
[[package]]
+name = "ungrammar2json"
+version = "1.0.0"
+dependencies = [
+ "ungrammar 1.16.1",
+ "write-json",
+]
+
+[[package]]
name = "unicase"
version = "2.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3707,7 +3719,7 @@ dependencies = [
"quote",
"stdx",
"time",
- "ungrammar",
+ "ungrammar 1.16.1 (registry+https://github.com/rust-lang/crates.io-index)",
"write-json",
"xflags",
"xshell",
diff --git a/Cargo.toml b/Cargo.toml
index ecb2686a22..6f5ea44401 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[workspace]
-members = ["xtask/", "lib/*", "crates/*"]
+members = ["xtask/", "lib/*", "lib/ungrammar/ungrammar2json", "crates/*"]
exclude = ["crates/proc-macro-srv/proc-macro-test/imp"]
resolver = "2"
@@ -42,7 +42,7 @@ debug = 2
# lsp-server = { path = "lib/lsp-server" }
-# ungrammar = { path = "../ungrammar" }
+# ungrammar = { path = "lin/ungrammar" }
# salsa = { path = "../salsa" }
# salsa-macros = { path = "../salsa/components/salsa-macros" }
diff --git a/lib/ungrammar/Cargo.toml b/lib/ungrammar/Cargo.toml
index 920d9ef49d..6e9dec7d6b 100644
--- a/lib/ungrammar/Cargo.toml
+++ b/lib/ungrammar/Cargo.toml
@@ -8,8 +8,6 @@ edition = "2018"
exclude = ["/bors.toml", "/.github"]
-[workspace]
-members = ["ungrammar2json"]
[dependencies]
# nope
diff --git a/lib/ungrammar/src/error.rs b/lib/ungrammar/src/error.rs
index 355e0b7ebc..144f9fc0e9 100644
--- a/lib/ungrammar/src/error.rs
+++ b/lib/ungrammar/src/error.rs
@@ -27,10 +27,7 @@ impl std::error::Error for Error {}
impl Error {
pub(crate) fn with_location(self, location: Location) -> Error {
- Error {
- location: Some(location),
- ..self
- }
+ Error { location: Some(location), ..self }
}
}
diff --git a/lib/ungrammar/src/parser.rs b/lib/ungrammar/src/parser.rs
index a4ce9c1202..70fbe1ac0b 100644
--- a/lib/ungrammar/src/parser.rs
+++ b/lib/ungrammar/src/parser.rs
@@ -1,4 +1,5 @@
//! Simple hand-written ungrammar parser.
+#![allow(clippy::disallowed_types)]
use std::collections::HashMap;
use crate::{
@@ -36,10 +37,7 @@ const DUMMY_RULE: Rule = Rule::Node(Node(!0));
impl Parser {
fn new(mut tokens: Vec<lexer::Token>) -> Parser {
tokens.reverse();
- Parser {
- tokens,
- ..Parser::default()
- }
+ Parser { tokens, ..Parser::default() }
}
fn peek(&self) -> Option<&lexer::Token> {
@@ -49,9 +47,7 @@ impl Parser {
self.tokens.iter().nth_back(n)
}
fn bump(&mut self) -> Result<lexer::Token> {
- self.tokens
- .pop()
- .ok_or_else(|| format_err!("unexpected EOF"))
+ self.tokens.pop().ok_or_else(|| format_err!("unexpected EOF"))
}
fn expect(&mut self, kind: TokenKind, what: &str) -> Result<()> {
let token = self.bump()?;
@@ -75,10 +71,7 @@ impl Parser {
let len = self.node_table.len();
let grammar = &mut self.grammar;
*self.node_table.entry(name.clone()).or_insert_with(|| {
- grammar.nodes.push(NodeData {
- name,
- rule: DUMMY_RULE,
- });
+ grammar.nodes.push(NodeData { name, rule: DUMMY_RULE });
Node(len)
})
}
@@ -127,11 +120,7 @@ fn rule(p: &mut Parser) -> Result<Rule> {
let rule = seq_rule(p)?;
alt.push(rule)
}
- let res = if alt.len() == 1 {
- alt.pop().unwrap()
- } else {
- Rule::Alt(alt)
- };
+ let res = if alt.len() == 1 { alt.pop().unwrap() } else { Rule::Alt(alt) };
Ok(res)
}
@@ -142,11 +131,7 @@ fn seq_rule(p: &mut Parser) -> Result<Rule> {
while let Some(rule) = opt_atom_rule(p)? {
seq.push(rule)
}
- let res = if seq.len() == 1 {
- seq.pop().unwrap()
- } else {
- Rule::Seq(seq)
- };
+ let res = if seq.len() == 1 { seq.pop().unwrap() } else { Rule::Seq(seq) };
Ok(res)
}
@@ -175,10 +160,7 @@ fn opt_atom_rule(p: &mut Parser) -> Result<Option<Rule>> {
p.bump()?;
p.bump()?;
let rule = atom_rule(p)?;
- let res = Rule::Labeled {
- label,
- rule: Box::new(rule),
- };
+ let res = Rule::Labeled { label, rule: Box::new(rule) };
return Ok(Some(res));
}
_ => (),
diff --git a/lib/ungrammar/ungrammar2json/src/main.rs b/lib/ungrammar/ungrammar2json/src/main.rs
index f588ed5eb6..3e88458069 100644
--- a/lib/ungrammar/ungrammar2json/src/main.rs
+++ b/lib/ungrammar/ungrammar2json/src/main.rs
@@ -1,3 +1,4 @@
+#![allow(clippy::print_stderr, clippy::print_stdout)]
use std::{
env,
io::{self, Read},