Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions crates/plotnik-lib/src/analyze/dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ use plotnik_core::{Interner, Symbol};

use super::symbol_table::SymbolTable;
use super::type_check::DefId;
use crate::parser::Ref;
use crate::parser::ast::Expr;
use crate::parser::{Expr, Ref};

/// Result of dependency analysis.
#[derive(Clone, Debug, Default)]
Expand Down
3 changes: 1 addition & 2 deletions crates/plotnik-lib/src/analyze/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ use super::utils::find_similar;
use super::visitor::{Visitor, walk};
use crate::diagnostics::{DiagnosticKind, Diagnostics};
use crate::parser::ast::{self, Expr, NamedNode};
use crate::parser::cst::{SyntaxKind, SyntaxToken};
use crate::parser::token_src;
use crate::parser::{SyntaxKind, SyntaxToken, token_src};
use crate::query::query::AstMap;
use crate::query::source_map::{SourceId, SourceMap};

Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/analyze/type_check/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use std::collections::{BTreeMap, HashMap, HashSet};

use crate::parser::ast::Expr;
use crate::parser::Expr;

use super::symbol::{DefId, Interner, Symbol};
use super::types::{
Expand Down
5 changes: 2 additions & 3 deletions crates/plotnik-lib/src/analyze/type_check/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ use crate::analyze::dependencies::DependencyAnalysis;
use crate::analyze::symbol_table::SymbolTable;
use crate::analyze::visitor::{Visitor, walk_alt_expr, walk_def, walk_named_node, walk_seq_expr};
use crate::diagnostics::{DiagnosticKind, Diagnostics};
use crate::parser::ast::{
use crate::parser::{
AltExpr, AltKind, AnonymousNode, CapturedExpr, Def, Expr, FieldExpr, NamedNode, QuantifiedExpr,
Ref, Root, SeqExpr, is_truly_empty_scope,
Ref, Root, SeqExpr, SyntaxKind, is_truly_empty_scope,
};
use crate::parser::cst::SyntaxKind;
use crate::query::source_map::SourceId;

/// Type annotation kind from `@capture :: Type` syntax.
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/analyze/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use indexmap::IndexMap;
use crate::analyze::dependencies::DependencyAnalysis;
use crate::analyze::symbol_table::{SymbolTable, UNNAMED_DEF};
use crate::diagnostics::Diagnostics;
use crate::parser::ast::Root;
use crate::parser::Root;
use crate::query::source_map::SourceId;

/// Run type inference on all definitions.
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/analyze/validation/anchors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use crate::SourceId;
use crate::analyze::visitor::{Visitor, walk_named_node, walk_seq_expr};
use crate::diagnostics::{DiagnosticKind, Diagnostics};
use crate::parser::ast::{NamedNode, Root, SeqExpr, SeqItem};
use crate::parser::{NamedNode, Root, SeqExpr, SeqItem};

pub fn validate_anchors(source_id: SourceId, ast: &Root, diag: &mut Diagnostics) {
let mut visitor = AnchorValidator {
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/analyze/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
//! }
//! ```

use crate::parser::ast::{
use crate::parser::{
AltExpr, AnonymousNode, CapturedExpr, Def, Expr, FieldExpr, NamedNode, QuantifiedExpr, Ref,
Root, SeqExpr,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/compile/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::analyze::type_check::{DefId, TypeContext};
use crate::bytecode::Nav;
use crate::bytecode::{InstructionIR, Label, ReturnIR, TrampolineIR};
use crate::emit::StringTableBuilder;
use crate::parser::ast::Expr;
use crate::parser::Expr;

use super::capture::CaptureEffects;
use super::error::{CompileError, CompileResult};
Expand Down
8 changes: 4 additions & 4 deletions crates/plotnik-lib/src/compile/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! for quantifier repeat iterations.

use crate::bytecode::Nav;
use crate::parser::ast::{Expr, SeqItem};
use crate::parser::{Expr, SeqItem};

// Re-export from parser for compile module consumers
pub use crate::parser::is_truly_empty_scope;
Expand Down Expand Up @@ -118,7 +118,7 @@ pub fn is_down_nav(nav: Option<Nav>) -> bool {

/// Extract the operator kind from an expression if it's a quantifier.
/// Unwraps CapturedExpr if present.
fn quantifier_operator_kind(expr: &Expr) -> Option<crate::parser::cst::SyntaxKind> {
fn quantifier_operator_kind(expr: &Expr) -> Option<crate::parser::SyntaxKind> {
let expr = match expr {
Expr::CapturedExpr(cap) => cap.inner()?,
e => e.clone(),
Expand All @@ -132,7 +132,7 @@ fn quantifier_operator_kind(expr: &Expr) -> Option<crate::parser::cst::SyntaxKin

/// Check if expression is optional (?) or star (*) - patterns that can match zero times.
pub fn is_skippable_quantifier(expr: &Expr) -> bool {
use crate::parser::cst::SyntaxKind;
use crate::parser::SyntaxKind;
quantifier_operator_kind(expr).is_some_and(|k| {
matches!(
k,
Expand All @@ -146,7 +146,7 @@ pub fn is_skippable_quantifier(expr: &Expr) -> bool {

/// Syntactic check for star/plus quantifier (fallback when type info unavailable).
pub fn is_star_or_plus_quantifier(expr: Option<&Expr>) -> bool {
use crate::parser::cst::SyntaxKind;
use crate::parser::SyntaxKind;
expr.and_then(quantifier_operator_kind).is_some_and(|k| {
matches!(
k,
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/compile/quantifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use crate::analyze::type_check::TypeId;
use crate::bytecode::Nav;
use crate::bytecode::{EffectIR, Label};
use crate::parser::SyntaxKind;
use crate::parser::ast::{self, Expr};
use crate::parser::cst::SyntaxKind;

use super::Compiler;
use super::capture::{CaptureEffects, check_needs_struct_wrapper, get_row_type_id};
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/compile/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::num::NonZeroU16;
use crate::analyze::type_check::TypeId;
use crate::bytecode::{CallIR, EffectIR, Label, MatchIR, MemberRef};
use crate::bytecode::{EffectOpcode, Nav};
use crate::parser::ast::Expr;
use crate::parser::Expr;

use super::Compiler;
use super::capture::CaptureEffects;
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/parser/cst_tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::parser::cst::{QLang, SyntaxKind::*, TokenSet};
use super::cst::{QLang, SyntaxKind::*, TokenSet};
use rowan::Language;

#[test]
Expand Down
3 changes: 2 additions & 1 deletion crates/plotnik-lib/src/parser/grammar/structures.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use rowan::{Checkpoint, TextRange};

use super::utils::capitalize_first;
use crate::diagnostics::DiagnosticKind;
use crate::parser::Parser;
use crate::parser::cst::token_sets::{
Expand All @@ -9,6 +8,8 @@ use crate::parser::cst::token_sets::{
use crate::parser::cst::{SyntaxKind, TokenSet};
use crate::parser::lexer::token_text;

use super::utils::capitalize_first;

impl Parser<'_, '_> {
/// `(type ...)` | `(_ ...)` | `(ERROR)` | `(MISSING ...)` | `(RefName)` | `(expr/subtype)`
/// PascalCase without children → Ref; with children → error but parses as Tree.
Expand Down
3 changes: 2 additions & 1 deletion crates/plotnik-lib/src/parser/grammar/validation.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use rowan::TextRange;

use super::utils::{to_pascal_case, to_snake_case};
use crate::diagnostics::DiagnosticKind;
use crate::parser::Parser;

use super::utils::{to_pascal_case, to_snake_case};

impl Parser<'_, '_> {
/// Validate capture name follows plotnik convention (snake_case).
pub(crate) fn validate_capture_name(&mut self, name: &str, span: TextRange) {
Expand Down
3 changes: 1 addition & 2 deletions crates/plotnik-lib/src/parser/invariants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

#![cfg_attr(coverage_nightly, coverage(off))]

use crate::parser::SyntaxKind;

use super::core::Parser;
use super::cst::SyntaxKind;

impl Parser<'_, '_> {
#[inline]
Expand Down
6 changes: 4 additions & 2 deletions crates/plotnik-lib/src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
//! However, fuel exhaustion (exec_fuel, recursion_fuel) returns an actual error immediately.

pub mod ast;
pub mod cst;
pub mod lexer;
mod cst;
mod lexer;

mod core;
mod grammar;
Expand All @@ -47,3 +47,5 @@ pub use ast::{
};

pub use core::{ParseResult, Parser};

pub use lexer::{Token, lex, token_text};
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/query/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ impl<'q> QueryPrinter<'q> {
depth: usize,
w: &mut impl Write,
) -> std::fmt::Result {
use crate::parser::cst::SyntaxKind;
use crate::parser::SyntaxKind;
for child in node.children() {
if child.kind() == SyntaxKind::Anchor {
self.mark_anchor(depth, w)?;
Expand Down
2 changes: 1 addition & 1 deletion crates/plotnik-lib/src/query/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::analyze::symbol_table::{SymbolTable, resolve_names};
use crate::analyze::type_check::{self, Arity, TypeContext};
use crate::analyze::validation::{validate_alt_kinds, validate_anchors};
use crate::analyze::{dependencies, validate_recursion};
use crate::parser::{Parser, Root, SyntaxNode, lexer::lex};
use crate::parser::{Parser, Root, SyntaxNode, lex};
use crate::query::source_map::{SourceId, SourceMap};

const DEFAULT_QUERY_PARSE_FUEL: u32 = 1_000_000;
Expand Down