Skip to content

Instantly share code, notes, and snippets.

@mvcisback
mvcisback / gist:71c375339a2d48a34650
Created July 22, 2014 23:45
Prototype Clang Tree Index
class ClangFileToIndex(File_To_Index):
pass # ClangFileToIndex definition
def env(vars_, tree):
# Setup environment variables for inspecting clang as runtime
# We'll store all the havested metadata in the plugins temporary folder.
temp_folder = os.path.join(tree.temp_folder, 'plugins', PLUGIN_NAME)
plugin_folder = os.path.join(tree.config.plugin_folder, PLUGIN_NAME)
flags = [
@mvcisback
mvcisback / gist:d108e58a607a8c9ea84a
Last active August 29, 2015 14:04
C TypeSigs tests for DXR
from nose.tools import eq_
from dxr.plugins.utils import FuncSig, c_type_sig
def test_capitalize_type():
eq_(c_type_sig(["int", "bool", "char"], "void"),
FuncSig([("Int", "Bool", "Char"), "Void"], []))
@mvcisback
mvcisback / gist:ee327e13a9a31cb02281
Last active August 29, 2015 14:04
C TypeSig queries

Simple Function

int foo(char bar, int x);

C Style

(int) (char, int)

Haskell Style Signature

2014-07-24 DXR 3wk move clang env stuff into the environment API 83321bb7-2259-47e1-bb80-50d3dc6e2f15
2014-07-25 DXR 5d needle utility functions d446dc4b-00d6-4c27-a5a1-bc240d4e120f
2014-07-25 DXR 2wk test IR 6d618f79-1c8f-45fb-8c6f-f4a70fe186dd
2014-07-26 DXR 8d add mock to requirements 296f1e59-08d2-4f82-bbbb-6c3aaf77b2b0
2014-07-25 mock requirment should go away with
proper config sys
2014-07-27 DXR 3d c needle tests 2920d438-e5a0-4fdc-abd4-cf7ef6d25fa4
2014-07-29 DXR 2d type sig tests 04f3ce0b-f2c0-43ef-b405-0e2c843c5a45
2014-07-29 DXR 6d support grouping needles by file and line 18ee752c-bda2-4f0f-b472-68bdc295360d
2014-07-29 DXR 2d make a list of potential queries for c type sigs 066e47ed-d41d-4991-866a-
from funcy import invoke, repeat
def train(training_data, is_spam):
return invoke(plugins, "train", repeat([training_data, is_spam]))
@mvcisback
mvcisback / convert.py
Last active August 29, 2015 14:05
pytd -> mypy stub
import ast
import click
import astunparse
from funcy import mapcat
from pytypedecl import pytd
from pytypedecl.parse import parser
from typing import Undefined
@mvcisback
mvcisback / gist:ce5c1c0028d055347def
Created August 20, 2014 17:55
Type Search Query Parsing
TYPE_STR_GRAMMAR = Grammar(r"""
start = _ "(" _ types _ ")" _ "->" _ type
types = type ((_ "," _ type)?)+
type = ident _ ("<" _ params _ ">" )? _ stars?
ident = ~r"[\w\$_]+"
stars = ~r"\*+"
params = ident ((_ "," _ ident)?)+
_ = ~r"\s*"
""")
{-# LANGUAGE GADTs #-}
data Input = Input
data Output = Output
data Digital = Digital
data Analog = Analog
data Pin a b where
DigitalOutput :: Pin Digital Output
DigitalInput :: Pin Digital Input
{
"metadata": {
"name": "",
"signature": "sha256:1ddd4a41de2fd581758a57a6abb740a94aabc0fdb33a638bbc55244b095d2f84"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
from infix import or_infix as infix
from more_itertools import consumer
@infix
def to(src, sink):
def _to():
for x in src:
sink.send(x)
return _to