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 Oxide Extractor 8 imports 5 functions

Entity Profile

Dependency Diagram

graph LR
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a["arbitrary_value_machine.rs"]
  04131242_d707_aa7f_6eae_68ca9c420039["super::ArbitraryValueMachine"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 04131242_d707_aa7f_6eae_68ca9c420039
  96a36755_a007_15e1_ec6c_526c02d24b9b["crate::cursor"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 96a36755_a007_15e1_ec6c_526c02d24b9b
  c4d29b89_2191_f275_13fb_7cf117340055["crate::extractor::bracket_stack::BracketStack"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> c4d29b89_2191_f275_13fb_7cf117340055
  05907c18_a40e_a5a9_c7c3_5faba98e1e87["crate::extractor::machine::"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 05907c18_a40e_a5a9_c7c3_5faba98e1e87
  97660f8c_0153_2876_c098_776592fda81c["crate::extractor::string_machine::StringMachine"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 97660f8c_0153_2876_c098_776592fda81c
  7a907858_c7d2_db19_0e89_e3d1d2242e48["classification_macros::ClassifyBytes"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 7a907858_c7d2_db19_0e89_e3d1d2242e48
  4d153f79_f78b_b66c_1e8a_11a0eb99bd41["crate::extractor::machine::Machine"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 4d153f79_f78b_b66c_1e8a_11a0eb99bd41
  433675ca_8d0e_feff_42a5_b3f666878cca["pretty_assertions::assert_eq"]
  b38ee3a8_b590_69c6_7df6_b73c4ec6b87a --> 433675ca_8d0e_feff_42a5_b3f666878cca
  style b38ee3a8_b590_69c6_7df6_b73c4ec6b87a 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 Oxide 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: 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