string_machine.rs — tailwindcss Source File
Architecture documentation for string_machine.rs, a rust file in the tailwindcss codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR e92d6055_7491_e838_01ff_8822a35d079f["string_machine.rs"] 80e7df54_9fb3_b5e8_c55a_fef5831aac69["super::StringMachine"] e92d6055_7491_e838_01ff_8822a35d079f --> 80e7df54_9fb3_b5e8_c55a_fef5831aac69 e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e["crate::cursor"] e92d6055_7491_e838_01ff_8822a35d079f --> e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e cd83abb6_a664_e16d_ddc8_60a3f23ba86a["crate::extractor::machine::"] e92d6055_7491_e838_01ff_8822a35d079f --> cd83abb6_a664_e16d_ddc8_60a3f23ba86a 5731c53a_0325_b3af_2918_bcb379bc8ec6["classification_macros::ClassifyBytes"] e92d6055_7491_e838_01ff_8822a35d079f --> 5731c53a_0325_b3af_2918_bcb379bc8ec6 9a9673b5_10d4_f716_360c_b2510082b102["crate::extractor::machine::Machine"] e92d6055_7491_e838_01ff_8822a35d079f --> 9a9673b5_10d4_f716_360c_b2510082b102 e4088d34_b5b4_ec51_b975_557a1536ec76["pretty_assertions::assert_eq"] e92d6055_7491_e838_01ff_8822a35d079f --> e4088d34_b5b4_ec51_b975_557a1536ec76 style e92d6055_7491_e838_01ff_8822a35d079f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
use crate::cursor;
use crate::extractor::machine::{Machine, MachineState};
use classification_macros::ClassifyBytes;
/// Extracts a string (including the quotes) from the input.
///
/// Rules:
///
/// - The string must start and end with the same quote character.
/// - The string cannot contain any whitespace characters.
/// - The string can contain any other character except for the quote character (unless it's escaped).
/// - Balancing of brackets is not required.
///
///
/// E.g.:
///
/// ```text
/// 'hello_world'
/// ^^^^^^^^^^^^^
///
/// content-['hello_world']
/// ^^^^^^^^^^^^^
/// ```
#[derive(Debug, Default)]
pub struct StringMachine;
impl Machine for StringMachine {
#[inline(always)]
fn reset(&mut self) {}
#[inline]
fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
if Class::Quote != cursor.curr.into() {
return MachineState::Idle;
}
// Start of a string
let len = cursor.input.len();
let start_pos = cursor.pos;
let end_char = cursor.curr;
cursor.advance();
while cursor.pos < len {
match cursor.curr.into() {
Class::Escape => match cursor.next.into() {
// An escaped whitespace character is not allowed
Class::Whitespace => return MachineState::Idle,
// An escaped character, skip ahead to the next character
_ => cursor.advance(),
},
// End of the string
Class::Quote if cursor.curr == end_char => return self.done(start_pos, cursor),
// Any kind of whitespace is not allowed
Class::Whitespace => return MachineState::Idle,
// Everything else is valid
// ... (79 more lines)
Domain
Subdomains
Dependencies
- classification_macros::ClassifyBytes
- crate::cursor
- crate::extractor::machine::
- crate::extractor::machine::Machine
- pretty_assertions::assert_eq
- super::StringMachine
Source
Frequently Asked Questions
What does string_machine.rs do?
string_machine.rs is a source file in the tailwindcss codebase, written in rust. It belongs to the OxideEngine domain, Extractor subdomain.
What functions are defined in string_machine.rs?
string_machine.rs defines 4 function(s): next, reset, test_string_machine_extraction, test_string_machine_performance.
What does string_machine.rs depend on?
string_machine.rs imports 6 module(s): classification_macros::ClassifyBytes, crate::cursor, crate::extractor::machine::, crate::extractor::machine::Machine, pretty_assertions::assert_eq, super::StringMachine.
Where is string_machine.rs in the architecture?
string_machine.rs is located at crates/oxide/src/extractor/string_machine.rs (domain: OxideEngine, subdomain: Extractor, directory: crates/oxide/src/extractor).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free