Skip to main content

sigil_parser/
lib.rs

1//! Sigil Parser Library
2//!
3//! A polysynthetic programming language with evidentiality types.
4//!
5//! This crate provides:
6//! - Lexer and parser for Sigil source code
7//! - Tree-walking interpreter for development/debugging
8//! - JIT compiler using Cranelift for native performance
9//! - Comprehensive optimization passes (O0-O3)
10//! - Rich diagnostic reporting with colored output
11//! - AI-facing IR for tooling and agent integration
12
13use std::sync::atomic::{AtomicBool, Ordering};
14
15/// Global verbose flag for debug output control.
16/// Set via `set_verbose(true)` or `--verbose` CLI flag.
17static VERBOSE: AtomicBool = AtomicBool::new(false);
18
19/// Enable or disable verbose debug output.
20pub fn set_verbose(enabled: bool) {
21    VERBOSE.store(enabled, Ordering::SeqCst);
22}
23
24/// Check if verbose mode is enabled.
25pub fn is_verbose() -> bool {
26    VERBOSE.load(Ordering::SeqCst)
27}
28
29/// Print debug message only when verbose mode is enabled.
30#[macro_export]
31macro_rules! sigil_debug {
32    ($($arg:tt)*) => {
33        if $crate::is_verbose() {
34            eprintln!($($arg)*);
35        }
36    };
37}
38
39/// Print warning message only when verbose mode is enabled.
40#[macro_export]
41macro_rules! sigil_warn {
42    ($($arg:tt)*) => {
43        if $crate::is_verbose() {
44            eprintln!($($arg)*);
45        }
46    };
47}
48
49pub mod ast;
50pub mod diagnostic;
51pub mod ffi;
52pub mod interpreter;
53pub mod ir;
54pub mod lexer;
55pub mod lower;
56pub mod optimize;
57pub mod parser;
58pub mod plurality;
59pub mod span;
60pub mod stdlib;
61pub mod typeck;
62pub mod holographic;
63
64#[cfg(feature = "native")]
65pub mod lint;
66#[cfg(feature = "native")]
67pub mod tree_sitter_support;
68#[cfg(feature = "native")]
69pub mod fmt;
70
71// New v0.4.0 features
72#[cfg(feature = "lsp")]
73pub mod lsp;
74pub mod tome;
75
76#[cfg(feature = "jit")]
77pub mod codegen;
78
79#[cfg(feature = "llvm")]
80pub mod llvm_codegen;
81
82#[cfg(feature = "wasm")]
83pub mod wasm;
84
85#[cfg(feature = "protocol-core")]
86pub mod protocol;
87
88#[cfg(feature = "websocket")]
89pub mod websocket;
90
91#[cfg(feature = "playground")]
92pub mod playground_api;
93
94pub use ast::*;
95pub use diagnostic::{Diagnostic, DiagnosticBuilder, Diagnostics, FixSuggestion, Severity};
96pub use interpreter::{Evidence, Function, Interpreter, RuntimeError, Value};
97pub use ir::{IrDumpOptions, IrEvidence, IrFunction, IrModule, IrOperation, IrType};
98pub use lexer::{Lexer, Token};
99#[cfg(feature = "native")]
100pub use lint::{
101    lint_file, lint_source, lint_source_with_config, lint_directory, lint_directory_parallel,
102    lint_and_fix, apply_fixes, watch_directory,
103    LintConfig, LintConfigFile, LintSettings, LintId, LintLevel, LintCategory, Linter,
104    DirectoryLintResult, FixResult, WatchConfig, WatchResult,
105    // Phase 6: Suppressions, SARIF, Stats, Explain
106    Suppression, parse_suppressions, LintStats,
107    SarifReport, generate_sarif, generate_sarif_for_directory,
108    explain_lint, list_lints,
109    // Phase 7: Baseline support, CLI overrides, caching
110    Baseline, BaselineEntry, BaselineSummary, BaselineLintResult,
111    find_baseline, lint_with_baseline,
112    CliOverrides, config_with_overrides, lint_source_with_overrides,
113    LintCache, CacheEntry, CachedDiagnostic, CacheStats, IncrementalLintResult,
114    find_cache, lint_directory_incremental, CACHE_FILE,
115    // Phase 8: LSP support
116    LspSeverity, LspDiagnostic, LspRelatedInfo, LspCodeAction, LspTextEdit,
117    LspLintResult, LspServerState, lint_for_lsp,
118    // Phase 9: Git integration
119    GitIntegration, lint_changed_files, lint_changed_since, lint_files,
120    generate_pre_commit_hook, PRE_COMMIT_HOOK,
121    // Phase 10: Custom rules
122    CustomRule, CustomPattern, CustomRulesFile, CustomRuleMatch, CustomRuleChecker,
123    lint_with_custom_rules,
124    // Phase 11: Ignore patterns
125    IgnorePatterns, filter_ignored, collect_sigil_files_filtered, lint_directory_filtered,
126    // Phase 12: HTML reports and trend tracking
127    LintReport, TrendData, TrendDirection, TrendSummary,
128    generate_html_report, save_html_report, CiFormat, generate_ci_annotations,
129};
130pub use lower::lower_source_file;
131pub use optimize::{optimize, OptLevel, OptStats, Optimizer};
132pub use parser::Parser;
133pub use span::Span;
134pub use stdlib::register_stdlib;
135pub use typeck::{EvidenceLevel, Type, TypeChecker, TypeError};
136
137#[cfg(feature = "jit")]
138pub use codegen::JitCompiler;
139
140#[cfg(feature = "llvm")]
141pub use llvm_codegen::llvm::{CompileMode, LlvmCompiler};
142
143#[cfg(feature = "wasm")]
144pub use wasm::WasmCompiler;