1extern crate self as antlr4_runtime;
4
5#[doc(hidden)]
7pub const __ANTLR4_RUST_CODEGEN_API: u32 = 3;
8
9#[doc(hidden)]
11#[macro_export]
12macro_rules! __antlr4_rust_require_codegen_api {
13 (1, $generator_version:literal) => {};
14 (2, $generator_version:literal) => {};
15 (3, $generator_version:literal) => {};
16 ($requested:literal, $generator_version:literal) => {
17 compile_error!(concat!(
18 "antlr4-rust generated-code API mismatch: antlr4-rust-gen v",
19 $generator_version,
20 " emitted generated-code API revision ",
21 stringify!($requested),
22 ", but the selected antlr-rust-runtime supports revisions 1, 2, and 3; regenerate this \
23 recognizer with a compatible antlr4-rust-gen or select a compatible \
24 antlr-rust-runtime dependency"
25 ));
26 };
27}
28
29pub mod atn;
30pub mod byte_stream;
31pub mod char_stream;
32pub mod dfa;
33pub mod errors;
34pub mod generated;
35pub mod int_stream;
36pub mod lexer;
37pub mod parser;
38#[cfg(feature = "perf-counters")]
39pub mod perf;
40pub mod prediction;
41pub mod recognizer;
42pub mod semir;
43pub mod token;
44pub mod token_stream;
45pub mod tree;
46pub mod tree_pattern;
47pub mod vocabulary;
48pub mod xpath;
49
50pub use atn::parser::{ParserAtnPrediction, ParserAtnSimulator, ParserAtnSimulatorError};
51pub use byte_stream::ByteStream;
52pub use char_stream::{CharStream, InputStream, PositionSummary, TextInterval};
53pub use dfa::{DfaStateId, DfaTransition, ParserDfa, ParserDfaStateView, ParserDfaStats};
54pub use errors::{AntlrError, ConsoleErrorListener, ErrorListener, SyntaxErrorEvent};
55pub use generated::{GeneratedLexer, GeneratedParser, GrammarMetadata};
56pub use int_stream::{EOF, IntStream, UNKNOWN_SOURCE_NAME};
57pub use lexer::{
58 BaseLexer, Lexer, LexerCustomAction, LexerLifecycleCtx, LexerMode, LexerPredicate, LexerSemCtx,
59 LexerSemIrCtx, LexerSemanticAction, LexerSemanticPredicate, LexerSemantics,
60};
61pub use parser::{
62 BailErrorStrategy, BaseParser, EnterRuleEvent, ExpectedTokenSet, NoSemanticHooks,
63 ParseListener, Parser, ParserAction, ParserMemberAction, ParserPredicate, ParserReturnAction,
64 ParserRuleArg, ParserRuntimeOptions, ParserSemCtx, ParserSemanticAction,
65 ParserSemanticPredicate, ParserSemantics, PredictionMode, RecognitionArenaStats, SemanticHooks,
66 UnknownSemanticPolicy, grow_generated_rule_stack,
67};
68#[cfg(feature = "perf-counters")]
69pub use perf::{dump as dump_prediction_perf_counters, reset as reset_prediction_perf_counters};
70pub use prediction::{ContextId, PredictionContextStats, SemanticContext};
71pub use recognizer::{Recognizer, RecognizerData};
72pub use token::{
73 DEFAULT_CHANNEL, HIDDEN_CHANNEL, INVALID_TOKEN_TYPE, MAX_TOKEN_OFFSET, TOKEN_EOF, Token,
74 TokenChannel, TokenId, TokenIter, TokenSink, TokenSource, TokenSpec, TokenStore,
75 TokenStoreError, TokenView,
76};
77pub use token_stream::CommonTokenStream;
78pub use tree::{
79 AsRuleNode, ErrorNodeView, FromRuleNode, GeneratedAttrs, MissingChildError, Node, NodeChildren,
80 NodeId, NodeKind, ParseTree, ParseTreeDescendants, ParseTreeListener, ParseTreeStats,
81 ParseTreeStorage, ParseTreeVisitor, ParseTreeWalker, ParsedFile, ParserRuleContext,
82 RuleNodeView, TerminalNodeView,
83};
84pub use tree_pattern::{
85 ParseTreeMatch, ParseTreePattern, ParseTreePatternError, ParseTreePatternMatcher, PatternLexer,
86 lex_pattern_chunk,
87};
88pub use vocabulary::Vocabulary;
89pub use xpath::{XPath, XPathError};
90
91pub fn java_style_list<T: std::fmt::Display>(items: &[T]) -> String {
99 let mut out = String::from("[");
100 for (index, item) in items.iter().enumerate() {
101 if index > 0 {
102 out.push_str(", ");
103 }
104 use std::fmt::Write;
105 write!(out, "{item}").expect("writing to a string cannot fail");
106 }
107 out.push(']');
108 out
109}