コード例 #1
0
ファイル: colors.py プロジェクト: kbfey/dirsearch
 def prepare_sequence_escaper(self):
     ESC = Literal("\x1b")
     integer = Word("0123456789")
     alphas = list("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz")
     self.escape_seq = Combine(ESC + "[" +
                               Optional(delimitedList(integer, ";")) +
                               oneOf(alphas))
    p_ParamValue_6 ^
    p_ParamValue_7 ^
    p_ParamValue_8)

# Parse action generator for vector types
def a__vec_gen(T):
    def a__vec(arg):
        t = T()
        if len(arg):
            for n in arg[0]:
                t.append(n)
        return t
    return a__vec

# Parse Vector Types
p_int32Vec << pp.Group(l + pp.Optional(pp.delimitedList(p_int)) + r)
p_int32Vec.setParseAction(a__vec_gen(messaging.int32Vec))
p_NodeOutputArcVec << pp.Group(l + pp.Optional(pp.delimitedList(p_NodeOutputArc)) + r)
p_NodeOutputArcVec.setParseAction(a__vec_gen(messaging.NodeOutputArcVec))
p_CornerVec << pp.Group(l + pp.Optional(pp.delimitedList(p_Corner)) + r)
p_CornerVec.setParseAction(a__vec_gen(messaging.CornerVec))
p_floatVec << pp.Group(l + pp.Optional(pp.delimitedList(p_float)) + r)
p_floatVec.setParseAction(a__vec_gen(messaging.floatVec))
p_LineVec << pp.Group(l + pp.Optional(pp.delimitedList(p_Line)) + r)
p_LineVec.setParseAction(a__vec_gen(messaging.LineVec))
p_KeyPointVec << pp.Group(l + pp.Optional(pp.delimitedList(p_KeyPoint)) + r)
p_KeyPointVec.setParseAction(a__vec_gen(messaging.KeyPointVec))
p_NodeInputVec << pp.Group(l + pp.Optional(pp.delimitedList(p_NodeInput)) + r)
p_NodeInputVec.setParseAction(a__vec_gen(messaging.NodeInputVec))
p_byteVec.setParseAction(a__vec_gen(messaging.byteVec))
p_CircleVec << pp.Group(l + pp.Optional(pp.delimitedList(p_Circle)) + r)
コード例 #3
0
# Parse action generator for vector types
def a__vec_gen(T):
    def a__vec(arg):
        t = T()
        if len(arg):
            for n in arg[0]:
                t.append(n)
        return t

    return a__vec


# Parse Vector Types
p_NodeOutputArcVec << pp.Group(l +
                               pp.Optional(pp.delimitedList(p_NodeOutputArc)) +
                               r)
p_NodeOutputArcVec.setParseAction(a__vec_gen(messaging.NodeOutputArcVec))
p_CornerVec << pp.Group(l + pp.Optional(pp.delimitedList(p_Corner)) + r)
p_CornerVec.setParseAction(a__vec_gen(messaging.CornerVec))
p_floatVec << pp.Group(l + pp.Optional(pp.delimitedList(p_float)) + r)
p_floatVec.setParseAction(a__vec_gen(messaging.floatVec))
p_LineVec << pp.Group(l + pp.Optional(pp.delimitedList(p_Line)) + r)
p_LineVec.setParseAction(a__vec_gen(messaging.LineVec))
p_KeyPointVec << pp.Group(l + pp.Optional(pp.delimitedList(p_KeyPoint)) + r)
p_KeyPointVec.setParseAction(a__vec_gen(messaging.KeyPointVec))
p_NodeInputVec << pp.Group(l + pp.Optional(pp.delimitedList(p_NodeInput)) + r)
p_NodeInputVec.setParseAction(a__vec_gen(messaging.NodeInputVec))
p_byteVec.setParseAction(a__vec_gen(messaging.byteVec))
p_CircleVec << pp.Group(l + pp.Optional(pp.delimitedList(p_Circle)) + r)
p_CircleVec.setParseAction(a__vec_gen(messaging.CircleVec))

# Parse action generator for vector types
def a__vec_gen(T):
    def a__vec(arg):
        t = T()
        if len(arg):
            for n in arg[0]:
                t.append(n)
        return t

    return a__vec


# Parse Vector Types
p_int32Vec << pp.Group(l + pp.Optional(pp.delimitedList(p_int)) + r)
p_int32Vec.setParseAction(a__vec_gen(messaging.int32Vec))
p_byteVec.setParseAction(a__vec_gen(messaging.byteVec))

# Special Case! Override byteVec definition
p_byteVec << pp.Optional(pp.Word(hexchars))


def a_byteVec(arg):
    if len(arg):
        return messaging.mkByteVec(arg[0])
    return messageing.byteVec()


p_byteVec.setParseAction(a_byteVec)
コード例 #5
0
ファイル: colors.py プロジェクト: bbhunter/dirsearch
 def prepare_sequence_escaper(self):
     ESC = Literal("\x1b")
     self.escape_seq = Combine(
         ESC + "[" + Optional(delimitedList(Word(string.digits), ";")) +
         oneOf(list(string.ascii_letters)))
コード例 #6
0
operand = Word(nums) | identifier  | parenthical
expression << operand + ZeroOrMore(arithOp + operand)
   
staticExpression = (integer | identifier | hexaValue | vectorValue | bitValue)

# Type information parser
subtypeIndication = Group(identifier + 
                          Optional(LPAR + Combine(expression) + 
                                   oneOf("TO DOWNTO", caseless=True) + 
                                   Combine(expression) + RPAR
                                   )
                          )

# Port declaration parser
portDecl = Group(identifier + COLON + mode + subtypeIndication)
portList = delimitedList(portDecl, delim=";").setResultsName("ports")

# Generic declaration parser
genericDecl = Group(identifier + COLON + subtypeIndication + 
                    Optional(EQUAL + staticExpression)
                    )
genericList = delimitedList(genericDecl, delim=";").setResultsName("generics")

# VHDL Entity declaration decoder
entityHeader = (CaselessLiteral("ENTITY").suppress() + entityIdent + 
    CaselessLiteral("IS").suppress()
    )

# Full VHDL Entity decoder
entityDecl = (SkipTo(entityHeader) + entityHeader +
              Optional(CaselessLiteral("GENERIC").suppress() + LPAR +