Home / File/ arbitrary_value_machine.rs — tailwindcss Source File

arbitrary_value_machine.rs — tailwindcss Source File

Architecture documentation for arbitrary_value_machine.rs, a rust file in the tailwindcss codebase. 8 imports, 0 dependents.

File rust OxideEngine Extractor 8 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0["arbitrary_value_machine.rs"]
  489d596c_ee54_308d_1065_6687cb88c625["super::ArbitraryValueMachine"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> 489d596c_ee54_308d_1065_6687cb88c625
  e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e["crate::cursor"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e
  94b5420b_055c_efe5_392d_b0d15e43aa35["crate::extractor::bracket_stack::BracketStack"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> 94b5420b_055c_efe5_392d_b0d15e43aa35
  cd83abb6_a664_e16d_ddc8_60a3f23ba86a["crate::extractor::machine::"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> cd83abb6_a664_e16d_ddc8_60a3f23ba86a
  9dfad5b5_43fe_bf7b_3e43_8f94b15347c9["crate::extractor::string_machine::StringMachine"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> 9dfad5b5_43fe_bf7b_3e43_8f94b15347c9
  5731c53a_0325_b3af_2918_bcb379bc8ec6["classification_macros::ClassifyBytes"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> 5731c53a_0325_b3af_2918_bcb379bc8ec6
  9a9673b5_10d4_f716_360c_b2510082b102["crate::extractor::machine::Machine"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> 9a9673b5_10d4_f716_360c_b2510082b102
  e4088d34_b5b4_ec51_b975_557a1536ec76["pretty_assertions::assert_eq"]
  2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 --> e4088d34_b5b4_ec51_b975_557a1536ec76
  style 2b32c2f1_30a5_e7bc_225e_f9c276ad26c0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use crate::cursor;
use crate::extractor::bracket_stack::BracketStack;
use crate::extractor::machine::{Machine, MachineState};
use crate::extractor::string_machine::StringMachine;
use classification_macros::ClassifyBytes;

/// Extracts arbitrary values including the brackets.
///
/// E.g.:
///
/// ```text
/// bg-[#0088cc]
///    ^^^^^^^^^
///
/// bg-red-500/[20%]
///            ^^^^^
/// ```
#[derive(Debug, Default)]
pub struct ArbitraryValueMachine {
    /// Track brackets to ensure they are balanced
    bracket_stack: BracketStack,

    string_machine: StringMachine,
}

impl Machine for ArbitraryValueMachine {
    #[inline(always)]
    fn reset(&mut self) {
        self.bracket_stack.reset();
    }

    #[inline]
    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
        // An arbitrary value must start with an open bracket
        if Class::OpenBracket != cursor.curr.into() {
            return MachineState::Idle;
        }

        let start_pos = cursor.pos;
        cursor.advance();

        let len = cursor.input.len();

        while cursor.pos < len {
            match cursor.curr.into() {
                Class::Escape => match cursor.next.into() {
                    // An escaped whitespace character is not allowed
                    //
                    // E.g.: `[color:var(--my-\ color)]`
                    //                         ^
                    Class::Whitespace => {
                        cursor.advance_twice();
                        return self.restart();
                    }

                    // An escaped character, skip the next character, resume after
                    //
                    // E.g.: `[color:var(--my-\#color)]`
                    //                        ^
                    _ => cursor.advance_twice(),
// ... (154 more lines)

Domain

Subdomains

Dependencies

  • classification_macros::ClassifyBytes
  • crate::cursor
  • crate::extractor::bracket_stack::BracketStack
  • crate::extractor::machine::
  • crate::extractor::machine::Machine
  • crate::extractor::string_machine::StringMachine
  • pretty_assertions::assert_eq
  • super::ArbitraryValueMachine

Frequently Asked Questions

What does arbitrary_value_machine.rs do?
arbitrary_value_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 arbitrary_value_machine.rs?
arbitrary_value_machine.rs defines 5 function(s): next, reset, test_arbitrary_value_machine_extraction, test_arbitrary_value_machine_performance, test_exceptions.
What does arbitrary_value_machine.rs depend on?
arbitrary_value_machine.rs imports 8 module(s): classification_macros::ClassifyBytes, crate::cursor, crate::extractor::bracket_stack::BracketStack, crate::extractor::machine::, crate::extractor::machine::Machine, crate::extractor::string_machine::StringMachine, pretty_assertions::assert_eq, super::ArbitraryValueMachine.
Where is arbitrary_value_machine.rs in the architecture?
arbitrary_value_machine.rs is located at crates/oxide/src/extractor/arbitrary_value_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