bropkg/engine/ast

    Dark Mode
Search:
Group by:

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
Program = ref object
  nodes*: seq[Node]
  selectors*: Table[string, Node]
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 call(node: Node): Node {....raises: [], tags: [].}
proc getColor(node: Node): string {....raises: [], tags: [].}
proc getInfixOp(kind: TokenKind; isInfixInfix: bool): InfixOp {....raises: [],
    tags: [].}
proc getString(node: Node): string {....raises: [], tags: [].}
proc markVarUsed(node: Node) {....raises: [], tags: [].}
proc newArray(): Node {....raises: [], tags: [].}
Create a new NTArray node
proc newBool(bVal: string): Node {....raises: [ValueError], tags: [].}
Create a new NTbool node
proc newCall(node: Node): Node {....raises: [], tags: [].}
Create a new NTCall node
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 newColor(cVal: string): Node {....raises: [], tags: [].}
Create a new NTColor node
proc newComment(str: string): Node {....raises: [], tags: [].}
Create a new NTComment node
proc newEcho(cmdValue: Node): Node {....raises: [], tags: [].}
proc newExtend(tk: TokenTuple; keyValueTable: KeyValueTable): Node {....raises: [],
    tags: [].}
Create a new NTExtend
proc newFloat(fVal: string): Node {....raises: [ValueError], tags: [].}
Create a new NTFloat node
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 newIf(infix: Node): Node {....raises: [], tags: [TimeEffect].}
Create a new NTCondStmt
proc newImport(nodes: seq[Node]; importPath: string): Node {....raises: [],
    tags: [].}
Create a new NTImport node
proc newImport(path: 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 newInfix(infixLeft: Node): Node {....raises: [], tags: [].}
Create a new NTInfix node
proc newInt(iVal: string): Node {....raises: [ValueError], tags: [].}
Create a new NTInt node
proc newJson(jsonVal: JsonNode): Node {....raises: [], tags: [].}
Create a new NTJsonValue node
proc newObject(): Node {....raises: [], tags: [].}
Create a new NTObject 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 newSize(size: int; unit: Units): Node {....raises: [], tags: [].}
proc newString(sVal: string): Node {....raises: [], tags: [].}
Create a new NTString node
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 newValue(val: 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: [].}