当前位置: 首页>>代码示例>>Python>>正文


Python Scanner.is_last_escaped方法代码示例

本文整理汇总了Python中Scanner.is_last_escaped方法的典型用法代码示例。如果您正苦于以下问题:Python Scanner.is_last_escaped方法的具体用法?Python Scanner.is_last_escaped怎么用?Python Scanner.is_last_escaped使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Scanner的用法示例。


在下文中一共展示了Scanner.is_last_escaped方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: parseRegexp

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
    def parseRegexp(self, scanner):
        # leading '/' is already consumed
        rexp = ""
        in_char_class = False
        token = scanner.next()
        while True:
            rexp += token.value      # accumulate token strings

            # -- Check last token
            # character classes
            if token.value == "[":
                if not Scanner.is_last_escaped(rexp): # i.e. not preceded by an odd number of "\"
                    in_char_class = True
            elif token.value == "]" and in_char_class:
                if not Scanner.is_last_escaped(rexp):
                    in_char_class = False
            # check for termination of rexp
            elif rexp[-1] == "/" and not in_char_class:  # rexp[-1] != token.value if token.value == "//"
                if not Scanner.is_last_escaped(rexp):
                    break

            token = scanner.next()

        # regexp modifiers
        try:
            if scanner.peek()[0].name == "ident":
                token = scanner.next()
                rexp += token.value
        except StopIteration:
            pass

        return rexp
开发者ID:Amsoft-Systems,项目名称:qooxdoo,代码行数:34,代码来源:tokenizer.py

示例2: parseString

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
def parseString(scanner, sstart):
    # parse string literals
    result = ""
    for token in scanner:
        result += token.value
        if token.value == sstart and not Scanner.is_last_escaped(result):  # be aware of escaped quotes
            break
    return result
开发者ID:mengu,项目名称:grooxdoo,代码行数:10,代码来源:tokenizer.py

示例3: parseCommentM

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
 def parseCommentM(self, scanner):
     res = []
     while True:
         token = scanner.next(r'\*/')  # inform the low-level scanner to switch to commentM
         res.append(token.value)
         if not Scanner.is_last_escaped(token.value):
             break
         # run-away comments bomb in the above scanner.next()
     return u"".join(res)
开发者ID:Amsoft-Systems,项目名称:qooxdoo,代码行数:11,代码来源:tokenizer.py

示例4: parseString

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
 def parseString(self, scanner, sstart):
     # parse string literals
     result = []
     while True:
         part = scanner.next(sstart)
         result.append(part.value)
         if not Scanner.is_last_escaped(part.value):  # be aware of escaped quotes
             break
         # run-away strings bomb in the above scanner.next()
     return u"".join(result)
开发者ID:Amsoft-Systems,项目名称:qooxdoo,代码行数:12,代码来源:tokenizer.py

示例5: parseCommentM

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
 def parseCommentM(self, scanner):
     res = []
     try:
         while True:
             token = scanner.next(r'\*/')  # inform the low-level scanner to switch to commentM
             res.append(token.value)
             if not Scanner.is_last_escaped(token.value):
                 break
     except StopIteration:
         raise SyntaxException("Unterminated multi-line comment:\n '%s'" % u''.join(res))
     return u"".join(res)
开发者ID:choubayu,项目名称:qooxdoo,代码行数:13,代码来源:tokenizer.py

示例6: parseString

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
 def parseString(self, scanner, sstart):
     # parse string literals
     result = []
     try:
         while True:
             part = scanner.next(sstart)
             result.append(part.value)
             if not Scanner.is_last_escaped(part.value):  # be aware of escaped quotes
                 break
     except StopIteration:
         raise SyntaxException("Unterminated string: '%s'" % u''.join(result))
     return u"".join(result)
开发者ID:choubayu,项目名称:qooxdoo,代码行数:14,代码来源:tokenizer.py

示例7: parseCommentM

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
def parseCommentM(scanner):
    result = []
    res = u""
    for token in scanner:
        result.append(token.value)
        if token.value == "*/":
            res = u"".join(result)
            if not Scanner.is_last_escaped(res):
                break
    else:
        res = u"".join(result)

    return res
开发者ID:mengu,项目名称:grooxdoo,代码行数:15,代码来源:tokenizer.py

示例8: parseCommentM1

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
def parseCommentM1(scanner):
    result = []
    res    = u""
    for token in scanner:
        result.append(token.value)
        if token.value == '*/':
            res = u"".join(result)
            if not Scanner.is_last_escaped(res):
                break
    else:
        # this means we've run out of tokens without finishing the comment
        res = u"".join(result)
        raise SyntaxException("Run-away comment", res)

    return res
开发者ID:carriercomm,项目名称:EyeOS,代码行数:17,代码来源:tokenizer.py

示例9: parseString

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
def parseString(scanner, sstart):
    # parse string literals
    result = []
    for token in scanner:
        result.append(token.value)
        if token.value == sstart:
            res = u"".join(result)
            if not Scanner.is_last_escaped(res):  # be aware of escaped quotes
                break
    else:
        # this means we've run out of tokens without finishing the string
        res = u"".join(result)
        raise SyntaxException("Non-terminated string", res)

    return res
开发者ID:carriercomm,项目名称:EyeOS,代码行数:17,代码来源:tokenizer.py

示例10: parseRegexp

# 需要导入模块: import Scanner [as 别名]
# 或者: from Scanner import is_last_escaped [as 别名]
def parseRegexp(scanner):
    # leading '/' is already consumed
    rexp = ""
    token = scanner.next()
    while True:
        rexp += token.value      # accumulate token strings
        if rexp.endswith("/"):   # check for end of regexp
            # make sure "/" is not escaped, ie. preceded by an odd number of "\"
            if not Scanner.is_last_escaped(rexp):
                break
        token = scanner.next()

    # regexp modifiers
    try:
        if scanner.peek()[0].name == "ident":
            token = scanner.next()
            rexp += token.value
    except StopIteration:
        pass

    return rexp
开发者ID:carriercomm,项目名称:EyeOS,代码行数:23,代码来源:tokenizer.py


注:本文中的Scanner.is_last_escaped方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。