How to use the ply.lex.NullLogger function in ply

To help you get started, we’ve selected a few ply examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github john-tornblom / llvm-p86 / llvm_p86 / tokens.py View on Github external
def scanner(debug=False):
    if debug:
        logger = lex.PlyLogger(sys.stderr)
    else:
        logger = lex.NullLogger()

    tab = "llvm_p86._p86_lextab"
    mod = sys.modules[__name__]
    return lex.lex(debuglog=logger,
                   errorlog=logger,
                   optimize=1,
                   lextab=tab,
                   outputdir=os.path.dirname(__file__),
                   module=mod)
github onicagroup / runway / src / runway / embedded / hcl / lexer.py View on Github external
def __init__(self):
        self.lex = lex.lex(
            module=self,
            debug=False,
            reflags=(re.UNICODE | re.MULTILINE),
            errorlog=lex.NullLogger(),
        )
github microsoft / ivy / ivy / ivy_lexer.py View on Github external
def t_NATIVEQUOTE(t):
    r'<<<[\s\S]*?>>>'
    t.lexer.lineno += sum(1 for c in t.value if c == '\n')
    t.type = reserved.get(t.value,'NATIVEQUOTE')
    return t

class TokenErrorNode(object):
    def __init__(self,token):
        self.lineno = iu.Location(iu.filename,token.lineno)

def t_error(t):
    raise iu.IvyError(TokenErrorNode(t),"illegal character '{}'".format(t.value[0]))
    print "Illegal character '%s'" % t.value[0]

lexer = lex.lex(errorlog=lex.NullLogger())

class LexerVersion(object):
    """ Context Manager that sets the lexer based on the given language version
    """
    def __init__(self,version):
        self.version = version
    def __enter__(self):
        global reserved
        self.orig_reserved = reserved
        reserved = dict(all_reserved)
#        print "version {}".format(self.version)
        if self.version <= [1,0]:
            for s in ['state','local']:
#                print "deleting {}".format(s)
                del reserved[s]
        if self.version <= [1,1]:
github john-tornblom / llvm-p86 / llvm_p86 / pre.py View on Github external
def scanner(debug=False):
    if debug:
        logger = lex.PlyLogger(sys.stderr)
    else:
        logger = lex.NullLogger()

    tab = "llvm_p86._p86pre_lextab"
    mod = sys.modules[__name__]
    return lex.lex(debuglog=logger,
                   errorlog=logger,
                   optimize=1,
                   lextab=tab,
                   outputdir=os.path.dirname(__file__),
                   module=mod)
github nicolashernandez / PyRATA / pyrata / lexer.py View on Github external
def build(self, pattern, **kwargs):
    """
    Create a lexer.
    """
    self.lexer = lex.lex(module=self, errorlog=lex.NullLogger(), **kwargs) #
    self.lexer.input(pattern)
    self.storeLexTokenList()