[PATCH] semantic/bovine/c: Parse C++11 strongly typed enum
Ramkumar Ramachandra <[email protected]> Wed, 21 Jan 2015 17:50:26 -0500
| Newsgroups | gmane.emacs.cedet |
|---|---|
| Message-ID | <[email protected]> |
* semantic/bovine/c.by (ENUM, opt-enum-type): Add opt-enum-type argument to ENUM, that matches either a colon + typeformbase or nothing. * semantic/bovine/c.el (semantic-c-reconstitute token): Add :enum-type. Helped-by: David Engster <[email protected]> Signed-off-by: Ramkumar Ramachandra <[email protected]> --- lisp/cedet/semantic/bovine/c.by | 15 +++++++++++---- lisp/cedet/semantic/bovine/c.el | 1 + tests/cedet/semantic/tests/test.cpp | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lisp/cedet/semantic/bovine/c.by b/lisp/cedet/semantic/bovine/c.by index 8dc3a82..8d0911f 100644 --- a/lisp/cedet/semantic/bovine/c.by +++ b/lisp/cedet/semantic/bovine/c.by @@ -114,7 +114,7 @@ %token UNION "union" %put UNION summary "Union Type Declaration: union [name] { ... };" %token ENUM "enum" -%put ENUM summary "Enumeration Type Declaration: enum [name] { ... };" +%put ENUM summary "Enumeration Type Declaration: enum [name] [: type] { ... };" %token TYPEDEF "typedef" %put TYPEDEF summary "Arbitrary Type Declaration: typedef <typedeclaration> <name>;" %token CLASS "class" @@ -416,6 +416,12 @@ opt-name ( "" ) ; +opt-enum-type + : COLON typeformbase + ( ,$2 ) + | ;; EMPTY + ; + typesimple : struct-or-class opt-class opt-name opt-template-specifier opt-class-parents semantic-list @@ -434,9 +440,10 @@ typesimple | UNION opt-class opt-name unionparts (TYPE-TAG (car $3) $1 $4 nil :parent (car ,$2)) - | ENUM opt-class opt-name enumparts - (TYPE-TAG (car $3) $1 $4 nil - :parent (car ,$2)) + | ENUM opt-class opt-name opt-enum-type enumparts + (TYPE-TAG (car $3) $1 $5 nil + :parent (car ,$2) + :enum-type (car ,$4)) ;; Klaus Berndl: a typedef can be a typeformbase with all this ;; declmods stuff. | TYPEDEF declmods typeformbase cv-declmods typedef-symbol-list diff --git a/lisp/cedet/semantic/bovine/c.el b/lisp/cedet/semantic/bovine/c.el index d0e1a16..22463b6 100644 --- a/lisp/cedet/semantic/bovine/c.el +++ b/lisp/cedet/semantic/bovine/c.el @@ -1341,6 +1341,7 @@ Optional argument STAR and REF indicate the number of * and & in the typedef." :constant-flag (if (member "const" declmods) t nil) :typemodifiers (delete "const" declmods) :parent (car (nth 2 tokenpart)) + :enum-type (nth 3 tokenpart) :destructor-flag (if (car (nth 3 tokenpart) ) t) :constructor-flag (if constructor t) :function-pointer fcnpointer diff --git a/tests/cedet/semantic/tests/test.cpp b/tests/cedet/semantic/tests/test.cpp index 8bb27ed..a170c52 100644 --- a/tests/cedet/semantic/tests/test.cpp +++ b/tests/cedet/semantic/tests/test.cpp @@ -22,6 +22,11 @@ int simple1(int a) { } +enum typedenum : unsigned { + FIRST = 0UL, + SECOND = ~0UL +}; + struct foo1 { int test; }; -- 2.2.1 ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet