Exemplo n.º 1
0
def _AbbreviateToken(token, out):
    if token.id != Id.Lit_Chars:
        n1 = runtime.PrettyLeaf(token.id.name, runtime.Color_OtherConst)
        out.append(n1)

    n2 = runtime.PrettyLeaf(token.val, runtime.Color_StringConst)
    out.append(n2)
Exemplo n.º 2
0
def _AbbreviateToken(token, out):
    # type: (token, List[runtime._PrettyBase]) -> None
    if token.id != Id.Lit_Chars:
        n1 = runtime.PrettyLeaf(token.id.name, runtime.Color_OtherConst)
        out.append(n1)

    n2 = runtime.PrettyLeaf(token.val, runtime.Color_StringConst)
    out.append(n2)
Exemplo n.º 3
0
def _arith_expr__Var(obj):
  # type: (arith_expr__Var) -> Optional[runtime.PrettyNode]
  p_node = runtime.PrettyNode()
  p_node.abbrev = True
  p_node.node_type = '$'
  n = runtime.PrettyLeaf(str(obj.name), runtime.Color_StringConst)
  p_node.unnamed_fields.append(n)
  return p_node
Exemplo n.º 4
0
def _arith_expr__Const(obj):
  # type: (arith_expr__Const) -> Optional[runtime.PrettyNode]
  p_node = runtime.PrettyNode()
  p_node.abbrev = True
  p_node.node_type = ''  # omit it
  n = runtime.PrettyLeaf(str(obj.i), runtime.Color_OtherConst)
  p_node.unnamed_fields.append(n)
  return p_node
Exemplo n.º 5
0
def _arith_expr__Unary(obj):
  # type: (arith_expr__Unary) -> Optional[runtime.PrettyNode]

  p_node = runtime.PrettyNode()
  p_node.abbrev = True
  p_node.node_type = 'U'
  n = runtime.PrettyLeaf(str(obj.op), runtime.Color_StringConst)
  p_node.unnamed_fields.append(n)
  p_node.unnamed_fields.append(obj.a.AbbreviatedTree())  # type: ignore
  return p_node
Exemplo n.º 6
0
def _speck(obj):
    # type: (speck) -> PrettyNode
    """Always abbreviate a speck as the Id."""
    p_node = runtime.PrettyNode()
    p_node.abbrev = True
    p_node.node_type = ''  # don't show

    n1 = runtime.PrettyLeaf(obj.id.name, runtime.Color_OtherConst)
    p_node.unnamed_fields.append(n1)
    return p_node
Exemplo n.º 7
0
def _arith_expr__Binary(obj):
  # type: (arith_expr__Binary) -> Optional[runtime.PrettyNode]

  if obj.op == '=':  # test for fallback
    return None

  p_node = runtime.PrettyNode()
  p_node.abbrev = True
  p_node.node_type = 'B'
  n = runtime.PrettyLeaf(str(obj.op), runtime.Color_StringConst)
  p_node.unnamed_fields.append(n)
  p_node.unnamed_fields.append(obj.left.AbbreviatedTree())  # type: ignore
  p_node.unnamed_fields.append(obj.right.AbbreviatedTree())  # type: ignore
  return p_node