コード例 #1
0
ファイル: Comment.py プロジェクト: fthomasfr/qooxdoo
                    "text": line.strip()
                })

        # format texts
        for entry in attribs:
            if 'text' in entry and len(entry['text']) > 0:
                if format_:
                    entry["text"] = self.formatText(entry["text"])
                else:
                    entry["text"] = self.cleanupText(entry["text"])

        #from pprint import pprint
        #pprint( attribs)
        return attribs

    gr_at__default_ = (py.Suppress('@') + py.Word(py.alphas)('category') +
                       py.restOfLine("text"))

    ##
    # "@<hint> text"
    def parse_at__default_(self, line):
        grammar = self.gr_at__default_
        presult = grammar.parseString(line)
        res = {
            'category': presult.category,
            'text': presult.text.strip(),
        }
        return res

    # the next would be close to the spec (but huge!)
    #identi = py.Word(u''.join(lang.IDENTIFIER_CHARS_START), u''.join(lang.IDENTIFIER_CHARS_BODY))
コード例 #2
0
    | pp.Combine(pp.Suppress("%") + "rip") \

reg128 = \
    pp.Combine(pp.Suppress("%") + "xmm0") \
    | pp.Combine(pp.Suppress("%") + "xmm1") \
    | pp.Combine(pp.Suppress("%") + "xmm2") \
    | pp.Combine(pp.Suppress("%") + "xmm3") \
    | pp.Combine(pp.Suppress("%") + "xmm4") \
    | pp.Combine(pp.Suppress("%") + "xmm5") \
    | pp.Combine(pp.Suppress("%") + "xmm6") \
    | pp.Combine(pp.Suppress("%") + "xmm7")

register = reg8 | reg32 | reg64 | reg128

immediate = pp.Combine(
    pp.Suppress("$") + pp.Literal("0x") + pp.Word(pp.hexnums)) | pp.Combine(
        pp.Suppress("$") + pp.Optional("-") + pp.Word(pp.nums))

memory_offset = pp.Combine(pp.Optional("-") + pp.Word(pp.nums))
memory_base = register
memory_index = register
memory_scale = pp.Or(["1", "2", "4", "8"])

label = pp.Combine(pp.Literal("L$") + pp.Word(pp.alphas, pp.alphanums + "_"))

memory = pp.Group(\
    pp.Optional(memory_offset, default = "OFFSET") \
    + pp.Suppress("(") + pp.Optional(memory_base, default = "BASE") \
    + pp.Optional(pp.Suppress(",") + memory_index \
    + pp.Optional(pp.Suppress(",") + memory_scale)) \
    + pp.Suppress(")"))
コード例 #3
0
                })

        # format texts
        for entry in attribs:
            if 'text' in entry and len(entry['text'])>0:
                if format_:
                    entry["text"] = self.formatText(entry["text"])
                else:
                    entry["text"] = self.cleanupText(entry["text"])
 
        #from pprint import pprint
        #pprint( attribs)
        return attribs


    gr_at__default_ = ( py.Suppress('@') + py.Word(py.alphas)('category') + py.restOfLine("text") )
    ##
    # "@<hint> text" 
    def parse_at__default_(self, line):
        grammar = self.gr_at__default_
        presult = grammar.parseString(line)
        res = {
            'category' : presult.category,
            'text' : presult.text.strip(),
        }
        return res

    # the next would be close to the spec (but huge!)
    #identi = py.Word(u''.join(lang.IDENTIFIER_CHARS_START), u''.join(lang.IDENTIFIER_CHARS_BODY))
    # but using regex, to be consistent with the parser
    py_js_identifier = py.Regex(lang.IDENTIFIER_REGEXP)
コード例 #4
0
ファイル: dslparse.py プロジェクト: rainoftime/CASM-Verify
    return [temp]

def parseFunction(s, loc, toks) :
    temp = di.Function(toks[0], toks[2], toks[3])
    return temp

lpar = pp.Literal("(")
rpar = pp.Literal(")")
shiftOpGroup = pp.oneOf(">> >>> << <<<")
andOpGroup = pp.oneOf("& | ^")
plusOpGroup = pp.oneOf("+ -")
multOpGroup = pp.oneOf("* /")
unOpGroup = pp.oneOf("!")
comparator = pp.oneOf("= > >= < <= == !=")

constant = pp.Combine(pp.Optional(pp.Literal("-")) + pp.Word(pp.hexnums)) + pp.Optional(pp.Combine(pp.Literal(":") + pp.Word(pp.hexnums)), default=":32")
tempVar = pp.Optional(pp.Combine(pp.Word(pp.alphas, pp.alphanums) + pp.Literal("."))) + pp.Word(pp.alphas, pp.alphanums + "_") + pp.Optional(pp.Combine(pp.Literal(":") + pp.Word(pp.hexnums)), default=":32")
hexConstant = pp.Combine("0x" + pp.Word(pp.hexnums)) + pp.Optional(pp.Combine(pp.Literal(":") + pp.Word(pp.hexnums)), default=":32")
label = pp.Combine(pp.Literal("L$") + pp.Word(pp.alphas, pp.alphanums + "_"))

orExpression = pp.Forward()
argList = (orExpression + pp.ZeroOrMore(pp.Suppress(pp.Literal(",")) + orExpression)).setParseAction(pushCallArg)
callVar = (tempVar + pp.Suppress(lpar) + pp.Optional(argList) + pp.Suppress(rpar)).setParseAction(pushCallVar)
arrayVar = (tempVar + pp.Suppress(pp.Literal("[")) + orExpression + pp.Suppress(pp.Literal("]"))).setParseAction(pushArrayVar)

factor = arrayVar | callVar | (label | tempVar | hexConstant | constant).setParseAction(CreateVar) | (pp.Suppress(pp.Literal("(")) + orExpression + pp.Suppress(pp.Literal(")")))

unaryExpression = ((unOpGroup + factor) | factor).setParseAction(pushUnaryExpr)
multExpression = unaryExpression + pp.ZeroOrMore(multOpGroup + unaryExpression)
multExpression.setParseAction(pushLeftAssocExpr)
plusExpression = multExpression + pp.ZeroOrMore(plusOpGroup + multExpression)