Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

canner compiler

Siou edited this page May 9, 2019 · 3 revisions

Canner Compiler compiles the data schema to a component tree that contains the Layout UI.

There are two parts of Canner Compiler: Parser and Traverser.

Parser

Parser initializes the component tree from the data schema.

interface

type Node = {
  nodeType: string,
  name?: string,
  [string]: any
}

type ParentNode = Node & {
  children: Array<Node>
}

type Tree = {
  [key: string]: ParentNode
}

Traverser

Traverser transforms the tree generated from Parser with the given visistors.

The operation is same as the Traveral of bable plugin

Visitor

interface

type Route = '';
type Path = {
  node: Node,
  parent: ParentNode,
  tree: Tree,
  route: Route
};
type Visitor = {
  [nodeType: $PropertyType<Node, 'node'>]: {
    enter?: (path: Path) => void;
    exit?: (path: Path) => void;
  }
}