Types
ArithmeticOperators {.pure.} = enum Invalid, Plus = "+", Minus = "-", Multi = "*", Div = "/", Modulo = "%"
CaseCondTuple = tuple[condOf: Node, body: seq[Node]]
ColorType = enum cNamed, cHex, cRGB, cRGBA, cHSL, cHSLA
CommandType = enum cmdEcho
GlobalValue = enum gInherit = "inherit", gInitial = "initial", gRevert = "revert", gRevertLayer = "revert-layer", gUnset = "unset"
InfixOp {.pure.} = enum None, EQ = "==", NE = "!=", GT = ">", GTE = ">=", LT = "<", LTE = "<=", AND = "and", OR = "or", AMP = "&"
KeyValueTable = OrderedTable[string, Node]
LengthType = enum Absolute, Relative
Node = ref object case nt*: NodeType of NTProperty: pName*: string pVal*: seq[Node] pRule*: PropertyRule of NTFunction: fnName: string fnParams: seq[Node] of NTComment: comment*: string of NTVariable: varName*: string varValue*: Node varMeta*: tuple[line, col: int] of NTVariableValue: val*: Node used*: bool of NTString: sVal*: string of NTInt: iVal*: int of NTFloat: fVal*: float of NTBool: bVal*: bool of NTColor: colorType*: ColorType colorGlobals: GlobalValue cVal*: string of NTArray: arrayVal*: seq[Node] usedArray*: bool of NTObject: objectPairs*: OrderedTable[string, Node] usedObject*: bool of NTAccessor: accessorType: NodeType of NTSize: sizeVal*: int sizeUnit*: Units lenType*: LengthType of NTJsonValue: jsonVal*: JsonNode usedJson*: bool of NTCall: callNode*: Node of NTInfix: infixOp*: InfixOp infixLeft*, infixRight*: Node of NTCondStmt: condOid*: Oid ifInfix*: Node ifBody*: seq[Node] elifNode*: seq[tuple[infix: Node, body: seq[Node]]] elseBody*: seq[Node] of NTCaseStmt: caseOid*: Oid caseIdent*: Node caseCond*: seq[CaseCondTuple] caseElse*: seq[Node] of NTImport: importNodes*: seq[Node] importPath*: string of NTPreview: previewContent: string of NTExtend: extendIdent*: string extendProps*: KeyValueTable of NTForStmt: forOid*: Oid forItem*, inItems*: Node forBody*: seq[Node] forScopes*: ScopeTable of NTMathStmt: mathInfixOp: ArithmeticOperators mathLeft, mathRight: Node of NTTagSelector, NTClassSelector, NTPseudoClassSelector, NTIDSelector: ident*: string parents*: seq[string] multipleSelectors*: seq[string] nested*: bool props*, pseudo*: KeyValueTable nodes*: seq[Node] extends*: bool extendFrom*, extendBy*: seq[string] identConcat*: seq[Node] of NTCommand: cmdIdent*: CommandType cmdValue*: Node else: nil aotStmts*: seq[Node]
NodeType = enum NTRoot, NTProperty, NTVariable, NTVariableValue, NTUniversalSelector, NTAttrSelector, NTClassSelector, NTPseudoClassSelector, NTPseudoElements, NTIDSelector, NTAtRule, NTFunction, NTComment, NTTagSelector, NTString, NTInt, NTFloat, NTBool, NTArray, NTObject, NTAccessor, NTColor, NTSize, NTJsonValue, NTCall, NTInfix, NTImport, NTPreview, NTExtend, NTForStmt, NTCondStmt, NTMathStmt, NTCaseStmt, NTCommand
PropertyRule = enum propRuleNone, propRuleDefault, propRuleImportant
ScopeTable = OrderedTableRef[string, Node]
Units = enum MM = "mm", CM = "cm", IN = "in", PX = "px", PT = "pt", PC = "pc", EM = "em", EX = "ex", CH = "ch", REM = "rem", VW = "vw", VH = "vh", VMIN = "vmin", VMAX = "vmax", PSIZE = "%"
Procs
proc getInfixOp(kind: TokenKind; isInfixInfix: bool): InfixOp {....raises: [], tags: [].}
proc markVarUsed(node: Node) {....raises: [], tags: [].}
proc newCaseStmt(caseIdent: Node): Node {....raises: [], tags: [].}
- Create a new NTCaseStmt
proc newClass(tk: TokenTuple; props = KeyValueTable(); multipleSelectors = @[""]; concat: seq[Node] = @[]): Node {. ...raises: [], tags: [].}
- Create a new NTClassSelector
proc newComment(str: string): Node {....raises: [], tags: [].}
- Create a new NTComment node
proc newExtend(tk: TokenTuple; keyValueTable: KeyValueTable): Node {....raises: [], tags: [].}
- Create a new NTExtend
proc newForStmt(item, items: Node; toPairs = false): Node {....raises: [], tags: [TimeEffect].}
- Create a new NTForStmt
proc newID(tk: TokenTuple; props = KeyValueTable(); multipleSelectors = @[""]; concat: seq[Node] = @[]): Node {....raises: [], tags: [].}
- Create a new NTIDSelector
proc newImport(nodes: seq[Node]; importPath: string): Node {....raises: [], tags: [].}
- Create a new NTImport node
proc newInfix(infixLeft, infixRight: Node; infixOp: InfixOp): Node {....raises: [], tags: [].}
- Create a new NTInfix node
proc newPreview(tk: TokenTuple): Node {....raises: [], tags: [].}
- Create a new NTPreview
proc newProperty(pName: string): Node {....raises: [], tags: [].}
- Create a new NTProperty node
proc newPseudoClass(tk: TokenTuple; props = KeyValueTable(); multipleSelectors = @[""]; concat: seq[Node] = @[]): Node {. ...raises: [], tags: [].}
- Create a new NTPseudoClassSelector
proc newTag(tk: TokenTuple; props = KeyValueTable(); multipleSelectors = @[""]; concat: seq[Node] = @[]): Node {....raises: [], tags: [].}
- Create a new NTTag node
proc newValue(tk: TokenTuple; valNode: Node): Node {....raises: [], tags: [].}
- Create a new NTVariableValue node
proc newVariable(tk: TokenTuple): Node {....raises: [], tags: [].}
- Create a new NTVariable (declaration) node
proc newVariable(varName: string; varValue: Node; tk: TokenTuple): Node {. ...raises: [], tags: [].}
- Create a new NTVariable (declaration) node
proc prefixed(tk: TokenTuple): string {....raises: [], tags: [].}