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 2fb50f57_27a6_296f_80b3_b44c47994dcb["string_machine.rs"] ad125679_4b4c_fb9a_f75b_c6dc8bc65df7["super::StringMachine"] 2fb50f57_27a6_296f_80b3_b44c47994dcb --> ad125679_4b4c_fb9a_f75b_c6dc8bc65df7 96a36755_a007_15e1_ec6c_526c02d24b9b["crate::cursor"] 2fb50f57_27a6_296f_80b3_b44c47994dcb --> 96a36755_a007_15e1_ec6c_526c02d24b9b 05907c18_a40e_a5a9_c7c3_5faba98e1e87["crate::extractor::machine::"] 2fb50f57_27a6_296f_80b3_b44c47994dcb --> 05907c18_a40e_a5a9_c7c3_5faba98e1e87 7a907858_c7d2_db19_0e89_e3d1d2242e48["classification_macros::ClassifyBytes"] 2fb50f57_27a6_296f_80b3_b44c47994dcb --> 7a907858_c7d2_db19_0e89_e3d1d2242e48 4d153f79_f78b_b66c_1e8a_11a0eb99bd41["crate::extractor::machine::Machine"] 2fb50f57_27a6_296f_80b3_b44c47994dcb --> 4d153f79_f78b_b66c_1e8a_11a0eb99bd41 433675ca_8d0e_feff_42a5_b3f666878cca["pretty_assertions::assert_eq"] 2fb50f57_27a6_296f_80b3_b44c47994dcb --> 433675ca_8d0e_feff_42a5_b3f666878cca style 2fb50f57_27a6_296f_80b3_b44c47994dcb 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 Oxide 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: Oxide, 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