Skip to content
This repository has been archived by the owner on Feb 20, 2022. It is now read-only.

packed, cppclass, fused, namespace are keywords (in some contexts) #20

Open
aldanor opened this issue Jul 2, 2014 · 2 comments
Open

Comments

@aldanor
Copy link

aldanor commented Jul 2, 2014

Example:

cdef packed struct Foo:
    pass

cdef extern from "foo.h" namespace "my::namespace":
    cdef cppclass A:
        pass

ctypedef fused int_or_float:
    int
    float

Looks like GitHub's syntax highlighter correctly picks it up (except namespace) :)

@aldanor aldanor changed the title packed, cppclass, namespace are keywords (in some contexts) packed, cppclass, fused, namespace are keywords (in some contexts) Jul 16, 2014
@petervaro petervaro added the bug label Oct 4, 2014
@petervaro
Copy link
Owner

@aldanor can you help me collecting all the valid cpp keywords/statements/types/etc which needed to be highlighted in cython? like for example: I found that the new statement is also valid in cython:

cdef Rectangle *rec = new Rectangle(1, 2, 3, 4)

Several examples and details could be found here.

@petervaro petervaro added enhancement and removed bug labels Oct 7, 2014
@aldanor
Copy link
Author

aldanor commented Oct 7, 2014

Alright, here's the list of Cython keywords and builtins that don't get highlighted (looking at the latest Cython v0.21) and their classification (similar keywords):

packed  # (same as public)
namespace # (same as extern)
cppclass # (same as class)
StandardError # (same as Exception)
xrange  # (same as range)
Py_ssize_t  # (standard type, used quite often)

That's just off the top of my head, maybe there's more...

Would also be nice to highlight standard C types from stdint which are used in Cython quite often:

int8_t, int16_t, ..., float32_t, .... etc

https://github.com/cython/cython/blob/master/Cython/Includes/libc/stdint.pxd

Some miscellaneous flaws I've noticed in highlighting:

x.readonly = 1

readonly shouldn't be highlighted since it's a wrong context (same thing with public, readonly, cdef, api etc -- note that types work fine so x.int or x.struct wouldn't get highlighted).

cdef object[int, ndim=1, mode="c"] buf1d = array(shape=(10,), itemsize=sizeof(int), format='i', mode='c')
cdef np.ndarray[dtype_t, ndim=3] a

ndim, mode etc should be highlighted the same way as keyword arguments to a function.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants