예제 #1
0
def _AbbreviateToken(tok, out):
    # type: (token, List[hnode_t]) -> None
    if tok.id != Id.Lit_Chars:
        n1 = runtime.NewLeaf(tok.id.name, color_e.OtherConst)
        out.append(n1)

    n2 = runtime.NewLeaf(tok.val, color_e.StringConst)
    out.append(n2)
예제 #2
0
def _expr__Const(obj):
    # type: (expr__Const) -> hnode_t
    p_node = runtime.NewRecord('Const')
    p_node.abbrev = True

    tok = obj.c
    out = p_node.unnamed_fields

    n1 = runtime.NewLeaf(tok.id.name, color_e.OtherConst)
    out.append(n1)

    n2 = runtime.NewLeaf(tok.val, color_e.StringConst)
    out.append(n2)
    return p_node
예제 #3
0
def _arith_expr__Var(obj):
  # type: (arith_expr__Var) -> hnode__Record
  p_node = runtime.NewRecord('$')
  p_node.abbrev = True
  n = runtime.NewLeaf(str(obj.name), color_e.StringConst)
  p_node.unnamed_fields.append(n)
  return p_node
예제 #4
0
def _arith_expr__Const(obj):
  # type: (arith_expr__Const) -> hnode__Record
  p_node = runtime.NewRecord('')
  p_node.abbrev = True
  n = runtime.NewLeaf(str(obj.i), color_e.OtherConst)
  p_node.unnamed_fields.append(n)
  return p_node
예제 #5
0
def _speck(obj):
    # type: (speck) -> hnode_t
    """Always abbreviate a speck as the Id."""
    p_node = runtime.NewRecord('')  # don't show node type
    p_node.abbrev = True

    n1 = runtime.NewLeaf(obj.id.name, color_e.OtherConst)
    p_node.unnamed_fields.append(n1)
    return p_node
예제 #6
0
def _expr__Var(obj):
    # type: (expr__Var) -> hnode_t
    p_node = runtime.NewRecord('Var')
    p_node.abbrev = True

    assert obj.name.id == Id.Expr_Name, obj.name
    n1 = runtime.NewLeaf(obj.name.val, color_e.StringConst)
    p_node.unnamed_fields.append(n1)
    return p_node
예제 #7
0
def _arith_expr__Unary(obj):
  # type: (arith_expr__Unary) -> hnode__Record

  p_node = runtime.NewRecord('U')
  p_node.abbrev = True
  n = runtime.NewLeaf(str(obj.op), color_e.StringConst)
  p_node.unnamed_fields.append(n)
  p_node.unnamed_fields.append(obj.a.AbbreviatedTree())  # type: ignore
  return p_node
예제 #8
0
def _arith_expr__Binary(obj):
  # type: (arith_expr__Binary) -> Optional[hnode__Record]

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

  p_node = runtime.NewRecord('B')
  p_node.abbrev = True
  n = runtime.NewLeaf(str(obj.op), color_e.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