Skip to main content

m2_syn/
lib.rs

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