Expore more internal data structures.
This commit is contained in:
parent
562731c154
commit
d9dca6ef98
@ -4,6 +4,8 @@ Rhai Release Notes
|
|||||||
Version 1.0.6
|
Version 1.0.6
|
||||||
=============
|
=============
|
||||||
|
|
||||||
|
* `MultiInputsStream`, `ParseState`, `TokenIterator`, `IdentifierBuilder` and `AccessMode` are exported under the `internals` feature.
|
||||||
|
|
||||||
|
|
||||||
Version 1.0.5
|
Version 1.0.5
|
||||||
=============
|
=============
|
||||||
|
@ -147,7 +147,8 @@ impl dyn Variant {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Modes of access.
|
/// _(internals)_ Modes of access.
|
||||||
|
/// Exported under the `internals` feature only.
|
||||||
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
|
#[derive(Debug, Eq, PartialEq, Hash, Copy, Clone)]
|
||||||
pub enum AccessMode {
|
pub enum AccessMode {
|
||||||
/// Mutable.
|
/// Mutable.
|
||||||
|
11
src/lib.rs
11
src/lib.rs
@ -212,7 +212,7 @@ pub use optimize::OptimizationLevel;
|
|||||||
|
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
#[deprecated = "this type is volatile and may change"]
|
#[deprecated = "this type is volatile and may change"]
|
||||||
pub use dynamic::{DynamicReadLock, DynamicWriteLock, Variant};
|
pub use dynamic::{AccessMode, DynamicReadLock, DynamicWriteLock, Variant};
|
||||||
|
|
||||||
// Expose internal data structures.
|
// Expose internal data structures.
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
@ -222,7 +222,14 @@ pub use token::{get_next_token, parse_string_literal};
|
|||||||
// Expose internal data structures.
|
// Expose internal data structures.
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
#[deprecated = "this type is volatile and may change"]
|
#[deprecated = "this type is volatile and may change"]
|
||||||
pub use token::{InputStream, Token, TokenizeState, TokenizerControl, TokenizerControlBlock};
|
pub use token::{
|
||||||
|
InputStream, MultiInputsStream, Token, TokenIterator, TokenizeState, TokenizerControl,
|
||||||
|
TokenizerControlBlock,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "internals")]
|
||||||
|
#[deprecated = "this type is volatile and may change"]
|
||||||
|
pub use parse::{IdentifierBuilder, ParseState};
|
||||||
|
|
||||||
#[cfg(feature = "internals")]
|
#[cfg(feature = "internals")]
|
||||||
#[deprecated = "this type is volatile and may change"]
|
#[deprecated = "this type is volatile and may change"]
|
||||||
|
26
src/parse.rs
26
src/parse.rs
@ -44,7 +44,8 @@ const SCOPE_SEARCH_BARRIER_MARKER: &str = "$BARRIER$";
|
|||||||
/// The message: never fails because `TokenStream` never ends
|
/// The message: never fails because `TokenStream` never ends
|
||||||
const NEVER_ENDS: &str = "never fails because `TokenStream` never ends";
|
const NEVER_ENDS: &str = "never fails because `TokenStream` never ends";
|
||||||
|
|
||||||
/// A factory of identifiers from text strings.
|
/// _(internals)_ A factory of identifiers from text strings.
|
||||||
|
/// Exported under the `internals` feature only.
|
||||||
///
|
///
|
||||||
/// When [`SmartString`](https://crates.io/crates/smartstring) is used as [`Identifier`],
|
/// When [`SmartString`](https://crates.io/crates/smartstring) is used as [`Identifier`],
|
||||||
/// this just returns a copy because most identifiers in Rhai are short and ASCII-based.
|
/// this just returns a copy because most identifiers in Rhai are short and ASCII-based.
|
||||||
@ -74,38 +75,39 @@ impl IdentifierBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type that encapsulates the current state of the parser.
|
/// _(internals)_ A type that encapsulates the current state of the parser.
|
||||||
|
/// Exported under the `internals` feature only.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ParseState<'e> {
|
pub struct ParseState<'e> {
|
||||||
/// Reference to the scripting [`Engine`].
|
/// Reference to the scripting [`Engine`].
|
||||||
engine: &'e Engine,
|
pub engine: &'e Engine,
|
||||||
/// Input stream buffer containing the next character to read.
|
/// Input stream buffer containing the next character to read.
|
||||||
tokenizer_control: TokenizerControl,
|
pub tokenizer_control: TokenizerControl,
|
||||||
/// Interned strings.
|
/// Interned strings.
|
||||||
interned_strings: IdentifierBuilder,
|
pub interned_strings: IdentifierBuilder,
|
||||||
/// Encapsulates a local stack with variable names to simulate an actual runtime scope.
|
/// Encapsulates a local stack with variable names to simulate an actual runtime scope.
|
||||||
stack: Vec<(Identifier, AccessMode)>,
|
pub stack: Vec<(Identifier, AccessMode)>,
|
||||||
/// Size of the local variables stack upon entry of the current block scope.
|
/// Size of the local variables stack upon entry of the current block scope.
|
||||||
entry_stack_len: usize,
|
pub entry_stack_len: usize,
|
||||||
/// Tracks a list of external variables (variables that are not explicitly declared in the scope).
|
/// Tracks a list of external variables (variables that are not explicitly declared in the scope).
|
||||||
#[cfg(not(feature = "no_closure"))]
|
#[cfg(not(feature = "no_closure"))]
|
||||||
external_vars: BTreeMap<Identifier, Position>,
|
pub external_vars: BTreeMap<Identifier, Position>,
|
||||||
/// An indicator that disables variable capturing into externals one single time
|
/// An indicator that disables variable capturing into externals one single time
|
||||||
/// up until the nearest consumed Identifier token.
|
/// up until the nearest consumed Identifier token.
|
||||||
/// If set to false the next call to [`access_var`][ParseState::access_var] will not capture the variable.
|
/// If set to false the next call to [`access_var`][ParseState::access_var] will not capture the variable.
|
||||||
/// All consequent calls to [`access_var`][ParseState::access_var] will not be affected
|
/// All consequent calls to [`access_var`][ParseState::access_var] will not be affected
|
||||||
#[cfg(not(feature = "no_closure"))]
|
#[cfg(not(feature = "no_closure"))]
|
||||||
allow_capture: bool,
|
pub allow_capture: bool,
|
||||||
/// Encapsulates a local stack with imported [module][crate::Module] names.
|
/// Encapsulates a local stack with imported [module][crate::Module] names.
|
||||||
#[cfg(not(feature = "no_module"))]
|
#[cfg(not(feature = "no_module"))]
|
||||||
modules: StaticVec<Identifier>,
|
pub modules: StaticVec<Identifier>,
|
||||||
/// Maximum levels of expression nesting.
|
/// Maximum levels of expression nesting.
|
||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
max_expr_depth: Option<NonZeroUsize>,
|
pub max_expr_depth: Option<NonZeroUsize>,
|
||||||
/// Maximum levels of expression nesting in functions.
|
/// Maximum levels of expression nesting in functions.
|
||||||
#[cfg(not(feature = "unchecked"))]
|
#[cfg(not(feature = "unchecked"))]
|
||||||
#[cfg(not(feature = "no_function"))]
|
#[cfg(not(feature = "no_function"))]
|
||||||
max_function_expr_depth: Option<NonZeroUsize>,
|
pub max_function_expr_depth: Option<NonZeroUsize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'e> ParseState<'e> {
|
impl<'e> ParseState<'e> {
|
||||||
|
25
src/token.rs
25
src/token.rs
@ -2057,15 +2057,17 @@ pub fn is_id_continue(x: char) -> bool {
|
|||||||
x.is_ascii_alphanumeric() || x == '_'
|
x.is_ascii_alphanumeric() || x == '_'
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A type that implements the [`InputStream`] trait.
|
/// _(internals)_ A type that implements the [`InputStream`] trait.
|
||||||
|
/// Exported under the `internals` feature only.
|
||||||
|
///
|
||||||
/// Multiple character streams are jointed together to form one single stream.
|
/// Multiple character streams are jointed together to form one single stream.
|
||||||
pub struct MultiInputsStream<'a> {
|
pub struct MultiInputsStream<'a> {
|
||||||
/// Buffered character, if any.
|
/// Buffered character, if any.
|
||||||
buf: Option<char>,
|
pub buf: Option<char>,
|
||||||
/// The current stream index.
|
/// The current stream index.
|
||||||
index: usize,
|
pub index: usize,
|
||||||
/// The input character streams.
|
/// The input character streams.
|
||||||
streams: StaticVec<Peekable<Chars<'a>>>,
|
pub streams: StaticVec<Peekable<Chars<'a>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputStream for MultiInputsStream<'_> {
|
impl InputStream for MultiInputsStream<'_> {
|
||||||
@ -2115,20 +2117,21 @@ impl InputStream for MultiInputsStream<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An iterator on a [`Token`] stream.
|
/// _(internals)_ An iterator on a [`Token`] stream.
|
||||||
|
/// Exported under the `internals` feature only.
|
||||||
pub struct TokenIterator<'a> {
|
pub struct TokenIterator<'a> {
|
||||||
/// Reference to the scripting `Engine`.
|
/// Reference to the scripting `Engine`.
|
||||||
engine: &'a Engine,
|
pub engine: &'a Engine,
|
||||||
/// Current state.
|
/// Current state.
|
||||||
state: TokenizeState,
|
pub state: TokenizeState,
|
||||||
/// Current position.
|
/// Current position.
|
||||||
pos: Position,
|
pub pos: Position,
|
||||||
/// External buffer containing the next character to read, if any.
|
/// External buffer containing the next character to read, if any.
|
||||||
tokenizer_control: TokenizerControl,
|
pub tokenizer_control: TokenizerControl,
|
||||||
/// Input character stream.
|
/// Input character stream.
|
||||||
stream: MultiInputsStream<'a>,
|
pub stream: MultiInputsStream<'a>,
|
||||||
/// A processor function that maps a token to another.
|
/// A processor function that maps a token to another.
|
||||||
map: Option<fn(Token) -> Token>,
|
pub map: Option<fn(Token) -> Token>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for TokenIterator<'a> {
|
impl<'a> Iterator for TokenIterator<'a> {
|
||||||
|
Loading…
Reference in New Issue
Block a user