How to use the pycparserext.ext_c_lexer.GnuCLexer function in pycparserext

To help you get started, we’ve selected a few pycparserext 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 inducer / pycparserext / pycparserext / ext_c_lexer.py View on Github external
class GnuCLexer(CLexerBase):
    # support '3i' for imaginary literal
    floating_constant = (
            '(((('
            + CLexerBase.fractional_constant+')'
            + CLexerBase.exponent_part+'?)|([0-9]+'
            + CLexerBase.exponent_part+'))i?[FfLl]?)')

    @TOKEN(floating_constant)
    def t_FLOAT_CONST(self, t):
        return t

    t_pppragma_ignore = ' \t<>.-{}();+-*/$%@&^~!?:,0123456789='


class GNUCLexer(GnuCLexer):
    def __init__(self, *args, **kwargs):
        from warnings import warn
        warn("GNUCLexer is now called GnuCLexer",
                DeprecationWarning, stacklevel=2)

        GnuCLexer.__init__(self, *args, **kwargs)


class OpenCLCLexer(CLexerBase):
    tokens = CLexerBase.tokens + ('LINECOMMENT',)
    states = (
            # ('comment', 'exclusive'),
            # ('preproc', 'exclusive'),
            ('ppline', 'exclusive'),  # unused
            ('pppragma', 'exclusive'),  # unused
            )
github inducer / pycparserext / pycparserext / ext_c_lexer.py View on Github external
return t


def add_lexer_keywords(cls, keywords):
    cls.keywords = cls.keywords + tuple(
            kw.upper() for kw in keywords)

    cls.keyword_map = cls.keyword_map.copy()
    cls.keyword_map.update(dict(
        (kw, kw.upper()) for kw in keywords))

    cls.tokens = cls.tokens + tuple(
            kw.upper() for kw in keywords)


add_lexer_keywords(GnuCLexer, [
    '__attribute__', '__asm__', '__asm', '__typeof__',
    '__real__', '__imag__', '__builtin_types_compatible_p',
    '__const', '__restrict', '__inline', '__inline__',
    '__extension__', 'asm', '__attribute'])

_CL_KEYWORDS = ['kernel', 'constant', 'global', 'local', 'private',
        "read_only", "write_only", "read_write"]
add_lexer_keywords(OpenCLCLexer, [
    '__attribute__', '__attribute', '__asm__', '__asm', 'asm']
    + _CL_KEYWORDS + ["__"+kw for kw in _CL_KEYWORDS])