From 53f1fb395f33e0fb8db9aebd09ea9082f650f9f1 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 28 Jun 2026 17:45:06 +0900 Subject: refactor: add linter --- .../src/seld/json_lint/json_parser.rs | 25 ++++++++++------------ 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs') diff --git a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs index 7cdf73b..317b4e5 100644 --- a/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs +++ b/crates/shirabe-external-packages/src/seld/json_lint/json_parser.rs @@ -1,13 +1,10 @@ //! ref: composer/vendor/seld/jsonlint/src/Seld/JsonLint/JsonParser.php -use std::collections::HashMap; - -use indexmap::IndexMap; -use shirabe_php_shim::PhpMixed; - use super::DuplicateKeyException; use super::ParsingException; use super::lexer::{Lexer, YylLoc}; +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; /// Semantic value held on the parser value stack ($vstack). Most values are JSON values (PhpMixed), /// but object members are represented as a `[key, value]` pair while being reduced. @@ -42,10 +39,10 @@ enum ActionResult { #[derive(Debug)] pub struct JsonParser { - productions_: HashMap, - terminals_: HashMap, - table: Vec>, - default_actions: HashMap, + productions_: IndexMap, + terminals_: IndexMap, + table: Vec>, + default_actions: IndexMap, } /// Per-parse mutable state. PHP keeps `$flags`/`$stack`/`$vstack`/`$lstack` on the parser instance; @@ -81,7 +78,7 @@ impl JsonParser { pub const ALLOW_DUPLICATE_KEYS_TO_ARRAY: u32 = 16; pub fn new() -> Self { - let productions_: HashMap = [ + let productions_: IndexMap = [ (1, (3, 1)), (2, (5, 1)), (3, (7, 1)), @@ -107,7 +104,7 @@ impl JsonParser { .into_iter() .collect(); - let terminals_: HashMap = [ + let terminals_: IndexMap = [ (2, "error"), (4, "STRING"), (6, "NUMBER"), @@ -127,7 +124,7 @@ impl JsonParser { let table = build_table(); - let default_actions: HashMap = [(16, (2, 6))].into_iter().collect(); + let default_actions: IndexMap = [(16, (2, 6))].into_iter().collect(); Self { productions_, @@ -790,9 +787,9 @@ fn trim_bytes(input: &[u8]) -> Vec { } /// Builds the LALR parse `table`. Indexed by state id (0..=31). -fn build_table() -> Vec> { +fn build_table() -> Vec> { use TableAction::{Action, Goto}; - let mut t: Vec> = (0..32).map(|_| HashMap::new()).collect(); + let mut t: Vec> = (0..32).map(|_| IndexMap::new()).collect(); let mut set = |state: usize, entries: &[(i64, TableAction)]| { for (sym, act) in entries { -- cgit v1.3.1