Home / File/ modifier_machine.rs — tailwindcss Source File

modifier_machine.rs — tailwindcss Source File

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

File rust OxideEngine Extractor 8 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b["modifier_machine.rs"]
  c60fd879_5c76_5fbf_df2f_7b3667f8fb01["super::ModifierMachine"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> c60fd879_5c76_5fbf_df2f_7b3667f8fb01
  e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e["crate::cursor"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> e4e20bdf_ad1e_e4a0_5cba_d0f5a5db787e
  b60f51a6_6e97_8e3d_707d_9068f03871c1["crate::extractor::arbitrary_value_machine::ArbitraryValueMachine"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> b60f51a6_6e97_8e3d_707d_9068f03871c1
  d66749b3_ce8e_5343_5587_7508eb703b11["crate::extractor::arbitrary_variable_machine::ArbitraryVariableMachine"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> d66749b3_ce8e_5343_5587_7508eb703b11
  cd83abb6_a664_e16d_ddc8_60a3f23ba86a["crate::extractor::machine::"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> cd83abb6_a664_e16d_ddc8_60a3f23ba86a
  5731c53a_0325_b3af_2918_bcb379bc8ec6["classification_macros::ClassifyBytes"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> 5731c53a_0325_b3af_2918_bcb379bc8ec6
  9a9673b5_10d4_f716_360c_b2510082b102["crate::extractor::machine::Machine"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> 9a9673b5_10d4_f716_360c_b2510082b102
  e4088d34_b5b4_ec51_b975_557a1536ec76["pretty_assertions::assert_eq"]
  2c61e6dd_1b50_c9dd_3887_d30248d91c0b --> e4088d34_b5b4_ec51_b975_557a1536ec76
  style 2c61e6dd_1b50_c9dd_3887_d30248d91c0b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

use crate::cursor;
use crate::extractor::arbitrary_value_machine::ArbitraryValueMachine;
use crate::extractor::arbitrary_variable_machine::ArbitraryVariableMachine;
use crate::extractor::machine::{Machine, MachineState};
use classification_macros::ClassifyBytes;

/// Extract modifiers from an input including the `/`.
///
/// E.g.:
///
/// ```text
/// bg-red-500/20
///           ^^^
///
/// bg-red-500/[20%]
///           ^^^^^^
///
/// bg-red-500/(--my-opacity)
///           ^^^^^^^^^^^^^^^
/// ```
#[derive(Debug, Default)]
pub struct ModifierMachine {
    arbitrary_value_machine: ArbitraryValueMachine,
    arbitrary_variable_machine: ArbitraryVariableMachine,
}

impl Machine for ModifierMachine {
    #[inline(always)]
    fn reset(&mut self) {}

    #[inline]
    fn next(&mut self, cursor: &mut cursor::Cursor<'_>) -> MachineState {
        // A modifier must start with a `/`, everything else is not a valid start of a modifier
        if Class::Slash != cursor.curr.into() {
            return MachineState::Idle;
        }

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

        match cursor.curr.into() {
            // Start of an arbitrary value:
            //
            // ```
            // bg-red-500/[20%]
            //            ^^^^^
            // ```
            Class::OpenBracket => match self.arbitrary_value_machine.next(cursor) {
                MachineState::Idle => self.restart(),
                MachineState::Done(_) => self.done(start_pos, cursor),
            },

            // Start of an arbitrary variable:
            //
            // ```
            // bg-red-500/(--my-opacity)
            //            ^^^^^^^^^^^^^^
            // ```
            Class::OpenParen => match self.arbitrary_variable_machine.next(cursor) {
                MachineState::Idle => self.restart(),
// ... (108 more lines)

Domain

Subdomains

Dependencies

  • classification_macros::ClassifyBytes
  • crate::cursor
  • crate::extractor::arbitrary_value_machine::ArbitraryValueMachine
  • crate::extractor::arbitrary_variable_machine::ArbitraryVariableMachine
  • crate::extractor::machine::
  • crate::extractor::machine::Machine
  • pretty_assertions::assert_eq
  • super::ModifierMachine

Frequently Asked Questions

What does modifier_machine.rs do?
modifier_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 modifier_machine.rs?
modifier_machine.rs defines 4 function(s): next, reset, test_modifier_extraction, test_modifier_machine_performance.
What does modifier_machine.rs depend on?
modifier_machine.rs imports 8 module(s): classification_macros::ClassifyBytes, crate::cursor, crate::extractor::arbitrary_value_machine::ArbitraryValueMachine, crate::extractor::arbitrary_variable_machine::ArbitraryVariableMachine, crate::extractor::machine::, crate::extractor::machine::Machine, pretty_assertions::assert_eq, super::ModifierMachine.
Where is modifier_machine.rs in the architecture?
modifier_machine.rs is located at crates/oxide/src/extractor/modifier_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