diff --git a/AGENTS.md b/AGENTS.md index e6d3f7e9..b8efc24f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,15 +10,16 @@ Lexer (logos) + parser (rowan) are resilient: collect errors, don't fail-fast. crates/ plotnik-lib/ # Core library src/ - ast/ # Syntax infrastructure + parser/ # Syntax infrastructure lexer.rs # Token definitions (logos) - syntax_kind.rs # SyntaxKind enum - nodes.rs # Typed AST wrappers over CST - parser/ - core.rs # Parser infrastructure - grammar.rs # Grammar rules - error.rs # Parse errors - tests/ # Parser tests (snapshots) + cst.rs # SyntaxKind enum + ast.rs # Typed AST wrappers over CST + core.rs # Parser infrastructure + grammar.rs # Grammar rules + error.rs # Parse errors + invariants.rs # Parser invariant checks + mod.rs # Re-exports, Parse struct, parse() + tests/ # Parser tests (snapshots) query/ # Query processing mod.rs # Query struct, new(), pipeline dump.rs # dump_* debug output methods @@ -38,7 +39,7 @@ docs/ ## Pipeline ```rust -ast::parse() // Parse → CST +parser::parse() // Parse → CST alt_kind::validate() // Validate alternation kinds named_defs::resolve() // Resolve names → SymbolTable ref_cycles::validate() // Validate recursion termination @@ -97,7 +98,7 @@ Stages: `Parse` → `Validate` → `Resolve` → `Escape`. Use `Query::errors_fo - New scopes only from captured `{...}@s` or `[...]@c` - `?`/`*`/`+` = optional/list/non-empty list -## AST Layer (`ast/nodes.rs`) +## AST Layer (`parser/ast.rs`) Types: `Root`, `Def`, `Tree`, `Ref`, `Str`, `Alt`, `Branch`, `Seq`, `Capture`, `Type`, `Quantifier`, `Field`, `NegatedField`, `Wildcard`, `Anchor`, `Expr` diff --git a/crates/plotnik-cli/src/commands/debug/mod.rs b/crates/plotnik-cli/src/commands/debug/mod.rs index b2d21563..0766f37b 100644 --- a/crates/plotnik-cli/src/commands/debug/mod.rs +++ b/crates/plotnik-cli/src/commands/debug/mod.rs @@ -4,7 +4,7 @@ use std::fs; use std::io::{self, Read}; use plotnik_lib::Query; -use plotnik_lib::ast::RenderOptions; +use plotnik_lib::RenderOptions; use source::{dump_source, load_source, parse_tree, resolve_lang}; diff --git a/crates/plotnik-lib/src/ast/mod.rs b/crates/plotnik-lib/src/ast/mod.rs deleted file mode 100644 index 40acecf0..00000000 --- a/crates/plotnik-lib/src/ast/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -//! Abstract syntax tree: parsing, syntax types, and typed node accessors. - -pub mod lexer; -pub mod nodes; -pub mod parser; -pub mod syntax_kind; - -#[cfg(test)] -mod lexer_tests; -#[cfg(test)] -mod nodes_tests; -#[cfg(test)] -mod syntax_kind_tests; - -pub use syntax_kind::{SyntaxKind, SyntaxNode, SyntaxToken}; - -pub use nodes::{ - Alt, AltKind, Anchor, Branch, Capture, Def, Expr, Field, NegatedField, Quantifier, Ref, Root, - Seq, Str, Tree, Type, Wildcard, -}; - -pub use parser::{Parse, parse}; - -pub use parser::{ - Diagnostic, ErrorStage, Fix, RelatedInfo, RenderOptions, Severity, SyntaxError, - render_diagnostics, render_errors, -}; diff --git a/crates/plotnik-lib/src/lib.rs b/crates/plotnik-lib/src/lib.rs index 41c17237..0349b8ff 100644 --- a/crates/plotnik-lib/src/lib.rs +++ b/crates/plotnik-lib/src/lib.rs @@ -17,10 +17,10 @@ #![cfg_attr(coverage_nightly, feature(coverage_attribute))] -pub mod ast; +pub mod parser; pub mod query; -pub use ast::{Diagnostic, RenderOptions, Severity}; +pub use parser::{Diagnostic, RenderOptions, Severity}; pub use query::{Query, QueryBuilder}; /// Errors that can occur during query parsing. diff --git a/crates/plotnik-lib/src/ast/nodes.rs b/crates/plotnik-lib/src/parser/ast.rs similarity index 99% rename from crates/plotnik-lib/src/ast/nodes.rs rename to crates/plotnik-lib/src/parser/ast.rs index 5f3d2005..3b53efb3 100644 --- a/crates/plotnik-lib/src/ast/nodes.rs +++ b/crates/plotnik-lib/src/parser/ast.rs @@ -3,7 +3,7 @@ //! Each struct wraps a `SyntaxNode` and provides typed accessors. //! Cast is infallible for correct `SyntaxKind` - validation happens elsewhere. -use super::syntax_kind::{SyntaxKind, SyntaxNode, SyntaxToken}; +use super::cst::{SyntaxKind, SyntaxNode, SyntaxToken}; macro_rules! ast_node { ($name:ident, $kind:ident) => { diff --git a/crates/plotnik-lib/src/ast/nodes_tests.rs b/crates/plotnik-lib/src/parser/ast_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/nodes_tests.rs rename to crates/plotnik-lib/src/parser/ast_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/core.rs b/crates/plotnik-lib/src/parser/core.rs similarity index 98% rename from crates/plotnik-lib/src/ast/parser/core.rs rename to crates/plotnik-lib/src/parser/core.rs index fd317a19..c68b5efd 100644 --- a/crates/plotnik-lib/src/ast/parser/core.rs +++ b/crates/plotnik-lib/src/parser/core.rs @@ -9,12 +9,12 @@ use rowan::{Checkpoint, GreenNode, GreenNodeBuilder, TextRange, TextSize}; +use super::cst::token_sets::ROOT_EXPR_FIRST; +use super::cst::{SyntaxKind, TokenSet}; use super::error::{Diagnostic, Fix, RelatedInfo}; +use super::lexer::{Token, token_text}; use crate::Error; -use crate::ast::lexer::{Token, token_text}; -use crate::ast::syntax_kind::token_sets::ROOT_EXPR_FIRST; -use crate::ast::syntax_kind::{SyntaxKind, TokenSet}; const DEFAULT_EXEC_FUEL: u32 = 1_000_000; const DEFAULT_RECURSION_FUEL: u32 = 4096; diff --git a/crates/plotnik-lib/src/ast/syntax_kind.rs b/crates/plotnik-lib/src/parser/cst.rs similarity index 100% rename from crates/plotnik-lib/src/ast/syntax_kind.rs rename to crates/plotnik-lib/src/parser/cst.rs diff --git a/crates/plotnik-lib/src/ast/syntax_kind_tests.rs b/crates/plotnik-lib/src/parser/cst_tests.rs similarity index 97% rename from crates/plotnik-lib/src/ast/syntax_kind_tests.rs rename to crates/plotnik-lib/src/parser/cst_tests.rs index 90b32f5e..03e18e88 100644 --- a/crates/plotnik-lib/src/ast/syntax_kind_tests.rs +++ b/crates/plotnik-lib/src/parser/cst_tests.rs @@ -1,4 +1,4 @@ -use crate::ast::syntax_kind::{QLang, SyntaxKind::*, TokenSet}; +use crate::parser::cst::{QLang, SyntaxKind::*, TokenSet}; use rowan::Language; #[test] diff --git a/crates/plotnik-lib/src/ast/parser/error.rs b/crates/plotnik-lib/src/parser/error.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/error.rs rename to crates/plotnik-lib/src/parser/error.rs diff --git a/crates/plotnik-lib/src/ast/parser/error_tests.rs b/crates/plotnik-lib/src/parser/error_tests.rs similarity index 99% rename from crates/plotnik-lib/src/ast/parser/error_tests.rs rename to crates/plotnik-lib/src/parser/error_tests.rs index 8b13ac32..30123179 100644 --- a/crates/plotnik-lib/src/ast/parser/error_tests.rs +++ b/crates/plotnik-lib/src/parser/error_tests.rs @@ -1,4 +1,4 @@ -use super::*; +use super::error::*; use rowan::TextRange; #[test] diff --git a/crates/plotnik-lib/src/ast/parser/grammar.rs b/crates/plotnik-lib/src/parser/grammar.rs similarity index 99% rename from crates/plotnik-lib/src/ast/parser/grammar.rs rename to crates/plotnik-lib/src/parser/grammar.rs index afb2e1d0..a6e7e083 100644 --- a/crates/plotnik-lib/src/ast/parser/grammar.rs +++ b/crates/plotnik-lib/src/parser/grammar.rs @@ -9,11 +9,11 @@ use super::core::Parser; use super::error::{Fix, RelatedInfo}; use super::invariants::assert_nonempty; -use crate::ast::lexer::token_text; -use crate::ast::syntax_kind::token_sets::{ +use super::cst::token_sets::{ ALT_RECOVERY, EXPR_FIRST, QUANTIFIERS, SEPARATORS, SEQ_RECOVERY, TREE_RECOVERY, }; -use crate::ast::syntax_kind::{SyntaxKind, TokenSet}; +use super::cst::{SyntaxKind, TokenSet}; +use super::lexer::token_text; impl Parser<'_> { pub fn parse_root(&mut self) { diff --git a/crates/plotnik-lib/src/ast/parser/invariants.rs b/crates/plotnik-lib/src/parser/invariants.rs similarity index 97% rename from crates/plotnik-lib/src/ast/parser/invariants.rs rename to crates/plotnik-lib/src/parser/invariants.rs index a51dadd4..ff2be6ff 100644 --- a/crates/plotnik-lib/src/ast/parser/invariants.rs +++ b/crates/plotnik-lib/src/parser/invariants.rs @@ -3,7 +3,7 @@ #![cfg_attr(coverage_nightly, coverage(off))] use super::core::Parser; -use crate::ast::syntax_kind::SyntaxKind; +use super::cst::SyntaxKind; impl Parser<'_> { #[inline] diff --git a/crates/plotnik-lib/src/ast/lexer.rs b/crates/plotnik-lib/src/parser/lexer.rs similarity index 98% rename from crates/plotnik-lib/src/ast/lexer.rs rename to crates/plotnik-lib/src/parser/lexer.rs index 9e765e66..a284665e 100644 --- a/crates/plotnik-lib/src/ast/lexer.rs +++ b/crates/plotnik-lib/src/parser/lexer.rs @@ -11,7 +11,7 @@ use logos::Logos; use rowan::TextRange; use std::ops::Range; -use super::syntax_kind::SyntaxKind; +use super::cst::SyntaxKind; /// Zero-copy token: kind + span, text retrieved via [`token_text`] when needed. #[derive(Debug, Clone, Copy, PartialEq, Eq)] diff --git a/crates/plotnik-lib/src/ast/lexer_tests.rs b/crates/plotnik-lib/src/parser/lexer_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/lexer_tests.rs rename to crates/plotnik-lib/src/parser/lexer_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/mod.rs b/crates/plotnik-lib/src/parser/mod.rs similarity index 79% rename from crates/plotnik-lib/src/ast/parser/mod.rs rename to crates/plotnik-lib/src/parser/mod.rs index eb3caab4..b76efb8b 100644 --- a/crates/plotnik-lib/src/ast/parser/mod.rs +++ b/crates/plotnik-lib/src/parser/mod.rs @@ -1,4 +1,4 @@ -//! Resilient LL parser for the query language. +//! Parser infrastructure for the query language. //! //! # Architecture //! @@ -20,43 +20,47 @@ //! 4. On recursion limit, remaining input goes into single Error node //! //! However, fuel exhaustion (exec_fuel, recursion_fuel) returns an error immediately. -//! -//! # Grammar (EBNF-ish) -//! -//! ```text -//! root = expr* -//! expr = tree | alternation | wildcard | anon_node -//! | anchor | negated_field | field | ident -//! tree = "(" [node_type] expr* ")" -//! alternation= "[" expr* "]" -//! wildcard = "_" -//! anon_node = STRING -//! capture = "@" LOWER_IDENT -//! anchor = "." -//! negated_field = "!" IDENT -//! field = IDENT ":" expr -//! quantifier = expr ("*" | "+" | "?" | "*?" | "+?" | "??") -//! capture = expr "@" IDENT ["::" TYPE] -//! ``` + +pub mod ast; +pub mod cst; +pub mod lexer; mod core; mod error; mod grammar; mod invariants; +#[cfg(test)] +mod ast_tests; +#[cfg(test)] +mod cst_tests; +#[cfg(test)] +mod error_tests; +#[cfg(test)] +mod lexer_tests; +#[cfg(test)] +mod tests; + +// Re-exports from cst (was syntax_kind) +pub use cst::{SyntaxKind, SyntaxNode, SyntaxToken}; + +// Re-exports from ast (was nodes) +pub use ast::{ + Alt, AltKind, Anchor, Branch, Capture, Def, Expr, Field, NegatedField, Quantifier, Ref, Root, + Seq, Str, Tree, Type, Wildcard, +}; + +// Re-exports from error pub use error::{ Diagnostic, ErrorStage, Fix, RelatedInfo, RenderOptions, Severity, SyntaxError, render_diagnostics, render_errors, }; +// Internal use pub(crate) use core::Parser; -use super::lexer::lex; -use super::syntax_kind::SyntaxNode; use crate::Result; - -#[cfg(test)] -mod error_tests; +use lexer::lex; /// Parse result containing the green tree and any errors. /// @@ -79,7 +83,7 @@ impl Parse { SyntaxNode::new_root(self.inner.green.clone()) } - pub fn errors(&self) -> &[SyntaxError] { + pub fn errors(&self) -> &[Diagnostic] { &self.inner.errors } @@ -106,6 +110,3 @@ pub(crate) fn parse_with_parser(mut parser: Parser) -> Result { inner: parser.finish()?, }) } - -#[cfg(test)] -mod tests; diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/alternations_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/alternations_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/alternations_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/alternations_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/anchors_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/anchors_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/anchors_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/anchors_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/captures_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/captures_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/captures_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/captures_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/definitions_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/definitions_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/definitions_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/definitions_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/fields_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/fields_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/fields_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/fields_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/mod.rs b/crates/plotnik-lib/src/parser/tests/grammar/mod.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/mod.rs rename to crates/plotnik-lib/src/parser/tests/grammar/mod.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/nodes_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/nodes_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/nodes_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/nodes_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/quantifiers_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/quantifiers_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/quantifiers_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/quantifiers_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/sequences_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/sequences_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/sequences_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/sequences_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/special_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/special_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/special_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/special_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/grammar/trivia_tests.rs b/crates/plotnik-lib/src/parser/tests/grammar/trivia_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/grammar/trivia_tests.rs rename to crates/plotnik-lib/src/parser/tests/grammar/trivia_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/json_serialization_tests.rs b/crates/plotnik-lib/src/parser/tests/json_serialization_tests.rs similarity index 97% rename from crates/plotnik-lib/src/ast/parser/tests/json_serialization_tests.rs rename to crates/plotnik-lib/src/parser/tests/json_serialization_tests.rs index edc34ef5..97ef7d15 100644 --- a/crates/plotnik-lib/src/ast/parser/tests/json_serialization_tests.rs +++ b/crates/plotnik-lib/src/parser/tests/json_serialization_tests.rs @@ -1,4 +1,4 @@ -use crate::ast::parser::parse; +use crate::parser::parse; #[test] fn error_json_serialization() { diff --git a/crates/plotnik-lib/src/ast/parser/tests/mod.rs b/crates/plotnik-lib/src/parser/tests/mod.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/mod.rs rename to crates/plotnik-lib/src/parser/tests/mod.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/recovery/coverage_tests.rs b/crates/plotnik-lib/src/parser/tests/recovery/coverage_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/recovery/coverage_tests.rs rename to crates/plotnik-lib/src/parser/tests/recovery/coverage_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/recovery/incomplete_tests.rs b/crates/plotnik-lib/src/parser/tests/recovery/incomplete_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/recovery/incomplete_tests.rs rename to crates/plotnik-lib/src/parser/tests/recovery/incomplete_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/recovery/mod.rs b/crates/plotnik-lib/src/parser/tests/recovery/mod.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/recovery/mod.rs rename to crates/plotnik-lib/src/parser/tests/recovery/mod.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/recovery/unclosed_tests.rs b/crates/plotnik-lib/src/parser/tests/recovery/unclosed_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/recovery/unclosed_tests.rs rename to crates/plotnik-lib/src/parser/tests/recovery/unclosed_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/recovery/unexpected_tests.rs b/crates/plotnik-lib/src/parser/tests/recovery/unexpected_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/recovery/unexpected_tests.rs rename to crates/plotnik-lib/src/parser/tests/recovery/unexpected_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/recovery/validation_tests.rs b/crates/plotnik-lib/src/parser/tests/recovery/validation_tests.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/recovery/validation_tests.rs rename to crates/plotnik-lib/src/parser/tests/recovery/validation_tests.rs diff --git a/crates/plotnik-lib/src/ast/parser/tests/validation/naming.rs b/crates/plotnik-lib/src/parser/tests/validation/naming.rs similarity index 100% rename from crates/plotnik-lib/src/ast/parser/tests/validation/naming.rs rename to crates/plotnik-lib/src/parser/tests/validation/naming.rs diff --git a/crates/plotnik-lib/src/query/alt_kind.rs b/crates/plotnik-lib/src/query/alt_kind.rs index a8089728..35a94bfa 100644 --- a/crates/plotnik-lib/src/query/alt_kind.rs +++ b/crates/plotnik-lib/src/query/alt_kind.rs @@ -8,8 +8,8 @@ use rowan::TextRange; use super::invariants::{ assert_alt_no_bare_exprs, assert_root_no_bare_exprs, ensure_both_branch_kinds, }; -use crate::ast::{Alt, AltKind, Branch, Expr, Root}; -use crate::ast::{Diagnostic, ErrorStage, RelatedInfo}; +use crate::parser::{Alt, AltKind, Branch, Expr, Root}; +use crate::parser::{Diagnostic, ErrorStage, RelatedInfo}; pub fn validate(root: &Root) -> Vec { let mut errors = Vec::new(); diff --git a/crates/plotnik-lib/src/query/dump.rs b/crates/plotnik-lib/src/query/dump.rs index 169929cc..2e2eb384 100644 --- a/crates/plotnik-lib/src/query/dump.rs +++ b/crates/plotnik-lib/src/query/dump.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod test_helpers { use crate::Query; - use crate::ast::{RenderOptions, render_diagnostics}; + use crate::parser::{RenderOptions, render_diagnostics}; impl Query<'_> { pub fn dump_cst(&self) -> String { diff --git a/crates/plotnik-lib/src/query/errors.rs b/crates/plotnik-lib/src/query/errors.rs index f9669fff..f3e59425 100644 --- a/crates/plotnik-lib/src/query/errors.rs +++ b/crates/plotnik-lib/src/query/errors.rs @@ -1,4 +1,4 @@ -use crate::ast::{Diagnostic, ErrorStage, RenderOptions, Severity, render_diagnostics}; +use crate::parser::{Diagnostic, ErrorStage, RenderOptions, Severity, render_diagnostics}; use super::Query; diff --git a/crates/plotnik-lib/src/query/errors_tests.rs b/crates/plotnik-lib/src/query/errors_tests.rs index 2aef77ac..2e1bbb0b 100644 --- a/crates/plotnik-lib/src/query/errors_tests.rs +++ b/crates/plotnik-lib/src/query/errors_tests.rs @@ -1,5 +1,5 @@ use super::Query; -use crate::ast::{ErrorStage, RenderOptions, Severity}; +use crate::parser::{ErrorStage, RenderOptions, Severity}; #[test] fn diagnostics_alias() { diff --git a/crates/plotnik-lib/src/query/invariants.rs b/crates/plotnik-lib/src/query/invariants.rs index bcc0a6ed..c29867f6 100644 --- a/crates/plotnik-lib/src/query/invariants.rs +++ b/crates/plotnik-lib/src/query/invariants.rs @@ -2,7 +2,7 @@ #![cfg_attr(coverage_nightly, coverage(off))] -use crate::ast::{Alt, Branch, Ref, Root, SyntaxNode, SyntaxToken}; +use crate::parser::{Alt, Branch, Ref, Root, SyntaxNode, SyntaxToken}; #[inline] pub fn assert_root_no_bare_exprs(root: &Root) { diff --git a/crates/plotnik-lib/src/query/mod.rs b/crates/plotnik-lib/src/query/mod.rs index a7e08cf6..092c1035 100644 --- a/crates/plotnik-lib/src/query/mod.rs +++ b/crates/plotnik-lib/src/query/mod.rs @@ -29,9 +29,9 @@ mod shape_cardinalities_tests; use std::collections::HashMap; use crate::Result; -use crate::ast::lexer::lex; -use crate::ast::parser::{self, Parser}; -use crate::ast::{Diagnostic, Parse, Root, SyntaxNode}; +use crate::parser::lexer::lex; +use crate::parser::{self, Parser}; +use crate::parser::{Diagnostic, Parse, Root, SyntaxNode}; use named_defs::SymbolTable; use shape_cardinalities::ShapeCardinality; diff --git a/crates/plotnik-lib/src/query/named_defs.rs b/crates/plotnik-lib/src/query/named_defs.rs index 2d8353c4..cf3f771f 100644 --- a/crates/plotnik-lib/src/query/named_defs.rs +++ b/crates/plotnik-lib/src/query/named_defs.rs @@ -7,8 +7,8 @@ use indexmap::{IndexMap, IndexSet}; use rowan::TextRange; -use crate::ast::{Diagnostic, ErrorStage}; -use crate::ast::{Expr, Ref, Root}; +use crate::parser::{Diagnostic, ErrorStage}; +use crate::parser::{Expr, Ref, Root}; #[derive(Debug, Clone)] pub struct SymbolTable { diff --git a/crates/plotnik-lib/src/query/printer.rs b/crates/plotnik-lib/src/query/printer.rs index ebdd015d..cb9ab63d 100644 --- a/crates/plotnik-lib/src/query/printer.rs +++ b/crates/plotnik-lib/src/query/printer.rs @@ -2,7 +2,7 @@ use std::fmt::Write; use rowan::NodeOrToken; -use crate::ast::{self, SyntaxNode}; +use crate::parser::{self as ast, SyntaxNode}; use super::Query; use super::shape_cardinalities::ShapeCardinality; diff --git a/crates/plotnik-lib/src/query/ref_cycles.rs b/crates/plotnik-lib/src/query/ref_cycles.rs index 84af54bf..2bd08673 100644 --- a/crates/plotnik-lib/src/query/ref_cycles.rs +++ b/crates/plotnik-lib/src/query/ref_cycles.rs @@ -7,8 +7,8 @@ use indexmap::{IndexMap, IndexSet}; use rowan::TextRange; use super::named_defs::SymbolTable; -use crate::ast::{Def, Expr, Root, SyntaxKind}; -use crate::ast::{Diagnostic, ErrorStage, RelatedInfo}; +use crate::parser::{Def, Expr, Root, SyntaxKind}; +use crate::parser::{Diagnostic, ErrorStage, RelatedInfo}; pub fn validate(root: &Root, symbols: &SymbolTable) -> Vec { let sccs = find_sccs(symbols); diff --git a/crates/plotnik-lib/src/query/shape_cardinalities.rs b/crates/plotnik-lib/src/query/shape_cardinalities.rs index 116d4358..197824b4 100644 --- a/crates/plotnik-lib/src/query/shape_cardinalities.rs +++ b/crates/plotnik-lib/src/query/shape_cardinalities.rs @@ -11,8 +11,8 @@ use super::invariants::{ assert_ref_in_symbols, ensure_ref_body, ensure_ref_name, panic_unexpected_node, }; use super::named_defs::SymbolTable; -use crate::ast::{Branch, Def, Expr, Field, Ref, Root, Seq, SyntaxNode, Type}; -use crate::ast::{Diagnostic, ErrorStage}; +use crate::parser::{Branch, Def, Expr, Field, Ref, Root, Seq, SyntaxNode, Type}; +use crate::parser::{Diagnostic, ErrorStage}; use std::collections::HashMap; #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]