;;; c.by -- LL grammar for C/C++ language specification
-
-;; Copyright (C) 1999-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1999-2014 Free Software Foundation, Inc.
;;
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; David Ponce <david@dponce.com>
;; > * Can't parse signature element: "RmcBucStatus* rftBucStatus"
%package semantic-c-by
+%provide semantic/bovine/c-by
+
+%{
+(declare-function semantic-c-reconstitute-token "semantic/bovine/c"
+ (tokenpart declmods typedecl))
+(declare-function semantic-c-reconstitute-template "semantic/bovine/c"
+ (tag specifier))
+(declare-function semantic-expand-c-tag "semantic/bovine/c" (tag))
+(declare-function semantic-parse-region "semantic"
+ (start end &optional nonterminal depth returnonerror))
+}
%languagemode c-mode c++-mode
%start declaration
%token <punctuation> PLUS "\\`[+]\\'"
%token <punctuation> MINUS "\\`[-]\\'"
%token <punctuation> BANG "\\`[!]\\'"
+%token <punctuation> QUESTION "\\`[?]\\'"
%token <punctuation> EQUAL "\\`[=]\\'"
%token <punctuation> LESS "\\`[<]\\'"
%token <punctuation> GREATER "\\`[>]\\'"
%put VIRTUAL summary "Method Modifier: virtual <type> <name>(...) ..."
%token MUTABLE "mutable"
%put MUTABLE summary "Member Declaration Modifier: mutable <type> <name> ..."
+%token EXPLICIT "explicit"
+%put EXPLICIT summary "Forbids implicit type conversion: explicit <constructor>"
%token STRUCT "struct"
%put STRUCT summary "Structure Type Declaration: struct [name] { ... };"
;; PUBLIC or PRIVATE bits. Ignore them for now.
| template
| using
+ ;; Includes inside namespaces
+ | spp-include
+ (TAG $1 'include :inside-ns t)
| ;;EMPTY
;
| declmods typeformbase cv-declmods opt-stars
opt-ref variablearg-opt-name
(TYPE-TAG (car $2) nil nil nil
+ :template-specifier (plist-get (nth 2 $2) :template-specifier)
:constant-flag (if (member "const" (append $1 $3)) t nil)
:typemodifiers (delete "const" (append $1 $3))
:reference (car ,$5)
:pointer (car $4)
+ :typevar (car $6)
)
;
opt-post-fcn-modifiers
: post-fcn-modifiers opt-post-fcn-modifiers
- ( ,(cons ,$1 $2) )
+ ( ,(cons ,(car $1) $2) )
| ;;EMPTY
( nil )
;
;; I should store more in this def, but leave it simple for now.
;; Klaus Berndl: const and volatile can be written after the type!
variablearg
- : declmods typeformbase cv-declmods opt-ref variablearg-opt-name
- ( VARIABLE-TAG (list $5) $2 nil
+ : declmods typeformbase cv-declmods opt-ref variablearg-opt-name opt-assign
+ ( VARIABLE-TAG (list (append $5 ,$6)) $2 nil
:constant-flag (if (member "const" (append $1 $3)) t nil)
:typemodifiers (delete "const" (append $1 $3))
:reference (car ,$4)
variablearg-opt-name
: varname
( ,$1 )
+ | semantic-list arg-list
+ ( (car ( EXPAND $1 function-pointer )) $2)
;; Klaus Berndl: This allows variableargs without a arg-name being
;; parsed correct even if there several pointers (*)
| opt-stars
varnamelist
: opt-ref varname varname-opt-initializer COMA varnamelist
- ( ,(cons $2 $5) )
+ ( ,(cons (append $2 $3) $5) )
| opt-ref varname varname-opt-initializer
- ( $2 )
+ ( (append $2 $3) )
;
;; Klaus Berndl: Is necessary to parse stuff like
;
function-pointer
- : LPAREN STAR symbol RPAREN
- ( (concat "*" $3) )
+ : LPAREN STAR opt-symbol RPAREN
+ ( (concat "*" ,(car $3)) )
+ | LPAREN symbol RPAREN
+ ( $2 )
;
fun-or-proto-end
: open-paren typeformbase close-paren
;
-opt-stuff-after-symbol
+opt-brackets-after-symbol
+ : brackets-after-symbol
+ | ;; EMPTY
+ ;
+
+brackets-after-symbol
: PAREN_BLCK
| BRACK_BLCK
- | ;; EMPTY
;
multi-stage-dereference
- : namespace-symbol opt-stuff-after-symbol PERIOD multi-stage-dereference ;; method call
- | namespace-symbol opt-stuff-after-symbol MINUS GREATER multi-stage-dereference ;;method call
- | namespace-symbol opt-stuff-after-symbol
+ : namespace-symbol opt-brackets-after-symbol
+ PERIOD multi-stage-dereference ;; method call
+ | namespace-symbol opt-brackets-after-symbol
+ MINUS GREATER multi-stage-dereference ;;method call
+ | namespace-symbol opt-brackets-after-symbol
+ PERIOD namespace-symbol opt-brackets-after-symbol
+ | namespace-symbol opt-brackets-after-symbol
+ MINUS GREATER namespace-symbol opt-brackets-after-symbol
+ | namespace-symbol brackets-after-symbol
;
string-seq
| AMPERSAND
| OR OR
| OR
+ | MOD
;; There are more.
;
;; Use expression for parsing only. Don't actually return anything
;; for now. Hopefully we can fix this later.
expression
- : unaryexpression expr-binop unaryexpression
+ : unaryexpression QUESTION unaryexpression COLON unaryexpression
+ ( (identity start) (identity end) )
+ | unaryexpression expr-binop unaryexpression
( (identity start) (identity end) )
| unaryexpression
( (identity start) (identity end) )
| multi-stage-dereference
| NEW multi-stage-dereference
| NEW builtintype-types semantic-list
- ;; Klaus Berndl: symbol -> namespace-symbol!
- | namespace-symbol
+ | symbol
;; Klaus Berndl: C/C++ allows sequences of strings which are
;; concatenated by the precompiler to one string
| string-seq