%token <tok> TSEMI TLBRACE TRBRACE TCOMMA TCOLON TASSIGN TLPAREN
%token <tok> TRPAREN TLSQBR TRSQBR TDOT TAMPERSAND TEXCL TTILDE
%token <tok> TMINUS TPLUS TMULT TDIV TPERCENT TLT TGT TCIRC TBAR TQUEST
-%token <tok> CSIZEOF CALIGNOF ARROW_OP CTYPEDEF COFFSETOF
+%token <tok> CSIZEOF CALIGNOF CTYPEOF ARROW_OP CTYPEDEF COFFSETOF
%token <tok> INC_OP DEC_OP LEFT_OP RIGHT_OP
%token <tok> LE_OP GE_OP EQ_OP NE_OP AND_OP OR_OP
%token <tok> MUL_ASSIGN DIV_ASSIGN MOD_ASSIGN ADD_ASSIGN SUB_ASSIGN
%type <expr> compoundStmt compoundStmtAux compoundStmtRest compoundStmtAuxErr
%type <expr> expressionStmt selectionStmt iterationStmt jumpStmt iterDefIterationStmt
%type <expr> stmtErr stmtListErr compoundStmtErr expressionStmtErr
-%type <expr> iterationStmtErr initializerList initializer ifPred whilePred forPred iterWhilePred
+%type <expr> iterationStmtErr initializerList typeInitializerList initializer
+%type <expr> ifPred whilePred forPred iterWhilePred typeInitializer
+
+%type <expr> designator designatorList designation
%type <typequal> storageSpecifier typeQualifier typeModifier globQual
%type <tquallist> optGlobQuals
| IsType TLPAREN NotType namedDecl IsType TRPAREN
{ $$ = idDecl_expectFunction ($4); }
| namedDeclBase TLSQBR TRSQBR
- { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
+ { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); }
| namedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
- exprNode_findValue($4);
+ exprNode_findValue ($4);
+ idDecl_notExpectingFunction ($1);
+
if (exprNode_hasValue ($4))
{
$$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1),
}
else
{
- $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1)));
+ $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1)));
}
}
| namedDeclBase PushType TLPAREN TRPAREN
| IsType TLPAREN NotType plainNamedDecl IsType TRPAREN
{ $$ = idDecl_expectFunction ($4); }
| plainNamedDeclBase TLSQBR TRSQBR
- { $$ = idDecl_replaceCtype ($1, ctype_makeArray (idDecl_getCtype ($1))); }
+ { $$ = idDecl_replaceCtype ($1, ctype_makeInnerArray (idDecl_getCtype ($1))); }
| plainNamedDeclBase TLSQBR IsType constantExpr TRSQBR NotType
{
int value;
value = 0;
}
- $$ = idDecl_replaceCtype ($1, ctype_makeFixedArray (idDecl_getCtype ($1), value));
+ $$ = idDecl_replaceCtype ($1, ctype_makeInnerFixedArray (idDecl_getCtype ($1), value));
}
| plainNamedDeclBase PushType TLPAREN TRPAREN
{ setCurrentParams (uentryList_missingParams); }
fcnDefHdrAux
: namedDecl
{
- qtype qint = qtype_create (ctype_int);
+ /**!!! deal with fred; fred (int); declarations! **/
+ qtype qint = qtype_create (ctype_int);
$$ = idDecl_fixBase ($1, qint);
qtype_free (qint);
}
| TLPAREN expr TRPAREN { $$ = exprNode_addParens ($1, $2); }
| TYPE_NAME_OR_ID { $$ = exprNode_fromIdentifier (coerceId ($1)); }
| QEXTENSION { $$ = exprNode_makeError (); }
+ | TLPAREN { exprChecks_inCompoundStatementExpression (); }
+ compoundStmt TRPAREN
+ { exprChecks_leaveCompoundStatementExpression (); $$ = exprNode_compoundStatementExpression ($1, $3); }
postfixExpr
: primaryExpr
| postfixExpr NotType ARROW_OP newId IsType { $$ = exprNode_arrowAccess ($1, $3, $4); }
| postfixExpr INC_OP { $$ = exprNode_postOp ($1, $2); }
| postfixExpr DEC_OP { $$ = exprNode_postOp ($1, $2); }
-
+ | TLPAREN typeExpression TRPAREN TLBRACE typeInitializerList optComma TRBRACE
+ { /* added for C99 */ $$ = exprNode_undefined; /*@i87 no checking */ }
+
argumentExprList
: assignExpr { $$ = exprNodeList_singleton ($1); }
| argumentExprList TCOMMA assignExpr { $$ = exprNodeList_push ($1, $3); }
: assignExpr
| TLBRACE initList TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); }
| TLBRACE initList TCOMMA TRBRACE { $$ = exprNode_makeInitBlock ($1, $2); }
+ | designation init { $$ = exprNode_undefined; }
+
+/*
+** Splint parses these (added in ISO C99), but no checking yet...
+*/
+
+designation
+ : designatorList TASSIGN { $$ = $1; }
+ | newId TCOLON { $$ = exprNode_undefined;
+ /* gcc extension, obsolete since 2.5 */ }
+designatorList
+ : designator { $$ = exprNode_undefined; }
+ | designatorList designator { $$ = exprNode_undefined; }
+
+designator
+ : TLSQBR constantExpr TRSQBR { $$ = exprNode_undefined; }
+ | TDOT newId { $$ = exprNode_undefined; }
initList
: init
| CGFLOAT NotType
| CDOUBLE NotType
| CVOID NotType
- | QANYTYPE NotType { $$ = ctype_unknown; }
+ | QANYTYPE NotType { $$ = ctype_makeAnytype (); }
| QINTEGRALTYPE NotType { $$ = ctype_anyintegral; }
| QUNSIGNEDINTEGRALTYPE NotType { $$ = ctype_unsignedintegral; }
| QSIGNEDINTEGRALTYPE NotType { $$ = ctype_signedintegral; }
| typeName NotType
| suSpc NotType
| enumSpc NotType
- | typeModifier NotType { $$ = ctype_fromQual ($1); }
+ | typeModifier NotType { $$ = ctype_fromQual ($1); }
completeType
: IsType completeTypeSpecifier IsType
CreateStructInnerScope
structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
TRBRACE
- optStructInvariant { {ctype ct; ct = declareStruct ($3, $8); /* setGlobalStructInfo(ct, $12);*/ $$ = ct;} }
+ optStructInvariant
+ { ctype ct; ct = declareStruct ($3, $8); /* setGlobalStructInfo(ct, $12);*/ $$ = ct; }
| NotType CUNION newId IsType TLBRACE { sRef_setGlobalScopeSafe (); }
CreateStructInnerScope
structDeclList DeleteStructInnerScope { sRef_clearGlobalScopeSafe (); }
{ $$ = declareUnnamedUnion ($7); }
| NotType CSTRUCT IsType TLBRACE TRBRACE
{ $$ = ctype_createUnnamedStruct (uentryList_new ()); }
- | NotType CUNION IsType TLBRACE TRBRACE
+ | NotType CUNION IsType TLBRACE TRBRACE
{ $$ = ctype_createUnnamedUnion (uentryList_new ()); }
| NotType CSTRUCT newId NotType { $$ = handleStruct ($3); }
- | NotType CUNION newId NotType { $$ = handleUnion ($3); }
+ | NotType CUNION newId NotType { $$ = handleUnion ($3); }
NotType
: { g_expectingTypeName = FALSE; }
| TLSQBR TRSQBR { $$ = ctype_makeArray (ctype_unknown); }
| TLSQBR constantExpr TRSQBR
{ $$ = ctype_makeFixedArray (ctype_unknown, exprNode_getLongValue ($2)); }
- | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeArray ($1); }
+ | abstractDeclBase TLSQBR TRSQBR { $$ = ctype_makeInnerArray ($1); }
| abstractDeclBase TLSQBR constantExpr TRSQBR
{ $$ = ctype_makeInnerFixedArray ($1, exprNode_getLongValue ($3)); }
| IsType TLPAREN TRPAREN
: initializer { $$ = $1; }
| initializerList initializer { $$ = exprNode_concat ($1, $2); }
+typeInitializerList
+ : typeInitializer { $$ = $1; }
+ | typeInitializerList TCOMMA typeInitializer { $$ = exprNode_concat ($1, $3); }
+
+typeInitializer
+ : assignExpr { $$ = $1; }
+ | TLBRACE typeInitializerList optComma TRBRACE { $$ = $2; }
+
stmtList
: stmt { $$ = $1; }
| stmtList stmt { $$ = exprNode_concat ($1, $2); }
:
| TSEMI { ; }
+optComma
+ :
+ | TCOMMA { ; }
+
id
: IDENTIFIER
typeName
: TYPE_NAME
| TYPE_NAME_OR_ID { $$ = ctype_unknown; }
+ | CTYPEOF TLPAREN expr TRPAREN { $$ = exprNode_getType ($3); exprNode_free ($3); }
+ | CTYPEOF TLPAREN typeExpression TRPAREN { $$ = qtype_getType ($3); }
%%