Skip to main content

m2_syn/
lib.rs

1#![doc = include_str!("../README.md")]
2#![warn(missing_docs)]
3#![warn(clippy::missing_errors_doc, clippy::missing_panics_doc)]
4
5extern crate self as m2_syn;
6
7// Files are grouped by the stage they belong to — `lex/`, `parser/`,
8// `migration/`, `schema/` — while the module paths stay flat, so `#[path]` carries the
9// grouping without renaming anything the rest of the crate refers to.
10
11// Declared first: these macros are textually scoped, so every module below
12// must come after their definitions.
13#[macro_use]
14#[path = "schema/macros.rs"]
15mod macros;
16
17#[path = "parser/body.rs"]
18mod body;
19#[path = "lex/cell_stream.rs"]
20mod cell_stream;
21#[path = "migration/cst.rs"]
22mod cst;
23#[path = "parser/delimited.rs"]
24mod delimited;
25#[path = "lex/lexer.rs"]
26pub mod lexer;
27// `expand!` reads this file during macro expansion; keep Cargo's dependency
28// tracking aware of the out-of-line source as well.
29const _: &str = include_str!("schema/nodes.rs");
30
31these_macros_should_be_illegal::expand!(
32    crate::__m2_syn_syntax;
33    /// Generated typed Macaulay2 syntax nodes and literal-token types.
34    #[macro_use]
35    #[path = "schema/nodes.rs"]
36    pub mod nodes;
37);
38mod expansion;
39#[path = "parser/native.rs"]
40pub mod native;
41#[path = "parser/parse.rs"]
42pub mod parse;
43mod parsed_file;
44#[cfg(feature = "pretty")]
45pub mod pretty;
46#[path = "parser/punctuated.rs"]
47pub mod punctuated;
48#[path = "parser/realtime.rs"]
49mod realtime;
50mod recovery;
51/// Internal support for span.
52mod span;
53#[path = "lex/token_stream.rs"]
54/// Internal support for token stream.
55mod token_stream;
56
57#[cfg(feature = "tree-sitter")]
58#[path = "migration/treesitter.rs"]
59pub mod treesitter;
60
61#[cfg(feature = "tree-sitter")]
62pub use treesitter::{
63    ParseError, RealtimeParser, TreeSitterParser, parse_file, parse_file_recovering, parse_tokens,
64};
65
66pub use parse::{
67    FragmentParseError, Parse, ParseStream, Parser, TokenParseError, migrate, parse_fragment_str,
68    parse_with, parse2,
69};
70
71pub use body::{Body, Terminated};
72pub use cell_stream::{
73    CellStream, CellStreamError, CellTokenGroup, CellTokenStream, CellTokenTree, Tokenize,
74};
75pub use cst::{
76    CSTNodeClassLabel, ChildCursor, ExternalCstChild, ExternalCstNode, Migrate, MigrateError, Token,
77};
78pub use delimited::Delimited;
79pub use expansion::ProcMacro;
80#[cfg(feature = "walk")]
81pub use expansion::{LiteralReturnTypes, LiteralReturnTypesError};
82#[doc(hidden)]
83pub use lexer::{__qualified_identifier_spans, __quote_fragment};
84pub use lexer::{LexError, LexErrorKind, lex, lex_recovering, lex_str, lex_str_recovering};
85#[cfg(not(any(feature = "pretty", feature = "walk")))]
86#[doc(hidden)]
87pub use m2_syn_macros::syntax as __m2_syn_syntax;
88#[cfg(all(feature = "pretty", not(feature = "walk")))]
89#[doc(hidden)]
90pub use m2_syn_macros::syntax_pretty as __m2_syn_syntax;
91#[cfg(all(feature = "pretty", feature = "walk"))]
92#[doc(hidden)]
93pub use m2_syn_macros::syntax_pretty_walk as __m2_syn_syntax;
94#[cfg(all(not(feature = "pretty"), feature = "walk"))]
95#[doc(hidden)]
96pub use m2_syn_macros::syntax_walk as __m2_syn_syntax;
97#[doc(hidden)]
98pub use m2_syn_macros::token as __m2_syn_token;
99pub use m2_syn_macros::{Spanned, parse_quote_m2, quote_m2};
100pub use native::{
101    CompletedNativeCell, NativeCellParser, NativeCellState, NativeParseError, NativeParser,
102    parse_native, parse_native_recovering,
103};
104pub(crate) use nodes::*;
105#[cfg(feature = "walk")]
106pub use nodes::{fold, visit, visit_mut};
107pub use parsed_file::ParsedFile;
108#[cfg(feature = "pretty")]
109pub use pretty::{
110    PrettyDetail, PrettyDetailRole, PrettyEdge, PrettyNode, PrettyNodeRole, PrettyOptions,
111    PrettyReport, PrettyTree, format_pretty_cell_tokens, format_pretty_tokens, format_pretty_tree,
112};
113pub use punctuated::{Punctuated, SeparatedPair};
114pub use realtime::{
115    NativeCellBoundary, NativeRealtimeCell, NativeRealtimeEditError, NativeRealtimeParser,
116};
117pub use recovery::Recovered;
118pub use span::{
119    File, LineColumn, LineColumnRange, Offset, Source, SourceId, Span, Spanned, TextEdit,
120};
121pub use these_macros_should_be_illegal::qf;
122#[doc(hidden)]
123pub use token_stream::delim::parse_delimiter;
124pub use token_stream::delim::{
125    Delimiter, DelimiterKind, DelimiterToken, DelimiterValue, DoubleSpan,
126};
127pub use token_stream::{
128    CommentTrivia, IdentToken, LeadingTrivia, Lex, LiteralKind, LiteralToken, Punct, Terminal,
129    TokenGroup, TokenStream, TokenTree, TrailingTrivia, Trivia, TriviaKind,
130};