package cascade

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Cascade.ComponentSource

Stage 3 IR: CSS Syntax section 5.1 component values and rules.

Stage 3 of the pipeline (chars -> lexer stream -> token stream -> AST): the output of Parser, consumed by the typed-AST validators.

Every node pairs its payload with the Loc.t spanning the source text it was parsed from. The _body records hold the structural fields; the corresponding types ending in node are the located wrappers.

Sourcetype 'a node = {
  1. node : 'a;
  2. loc : Loc.t;
}

A payload paired with the source range it occupies. Convention mirrors the ocaml-encodings skill's 'a node = 'a * Loc.Meta.t: every IR constructor is a located payload.

Sourcetype t =
  1. | Preserved of Token.t
  2. | Block of block node
  3. | Func of func node
Sourceand block = {
  1. opening : Token.bracket;
  2. value : t list;
  3. closed : bool;
    (*

    false when the lexer reached EOF before the matching closer (CSS Syntax §5.4.6 parse error). The serializer still emits the synthetic closer so reserialised output round-trips.

    *)
}
Sourceand func = {
  1. name : string;
  2. arguments : t list;
  3. terminated : bool;
    (*

    false when the lexer reached EOF before the matching ) (CSS Syntax section 5.4.6 parse error). The serializer still emits the synthetic ) so reserialised output round-trips through the lexer; typed validators can inspect this flag to reject values that the syntax level only forgives.

    *)
}
Sourcetype at_rule_body = {
  1. name : string;
  2. prelude : t list;
  3. block : block node option;
}
Sourcetype at_rule = at_rule_body node
Sourcetype qualified_rule_body = {
  1. prelude : t list;
  2. block : block node;
}
Sourcetype qualified_rule = qualified_rule_body node
Sourcetype rule =
  1. | Qualified of qualified_rule
  2. | At of at_rule
Sourcetype declaration_body = {
  1. name : string;
  2. value : t list;
  3. important : bool;
}
Sourcetype declaration = declaration_body node
Sourceval source_loc : t -> Loc.t

source_loc cv is the source range spanned by cv.

Sourceval rule_loc : rule -> Loc.t

rule_loc r is the source range spanned by rule r.

Sourceval pp : t Pp.t

pp renders a component value back to source-like text.

Sourceval to_string : t -> string

to_string t is the string rendering of pp.