X-Git-Url: http://andersk.mit.edu/gitweb/splint.git/blobdiff_plain/28bf4b0bfd405a2057d865910f8589c54a40f17b..b072092f32623dab70e6ffe1613740542ea66748:/src/cscanner.l diff --git a/src/cscanner.l b/src/cscanner.l index 6eeba4b..66405db 100644 --- a/src/cscanner.l +++ b/src/cscanner.l @@ -114,6 +114,8 @@ static /*@only@*/ cstring makeIdentifier (char *); /* yes, this is exported! */ bool g_expectingTypeName = TRUE; /* beginning of file can be type name! */ +static bool expectingMetaStateName = FALSE; + static int returnInt (ctype, long); static int returnFloat (ctype, double); static int returnChar (char); @@ -269,6 +271,7 @@ static void setTokLengthT (size_t len) "static" { setTokLength (6); RETURN_TOK (QSTATIC); } \"(\\.|[^\\"])*\"([ \t\n]*\"(\\.|[^\\"])*\")* { RETURN_EXPR (processString ()); } +L\"(\\.|[^\\"])*\"([ \t\n]*\"(\\.|[^\\"])*\")* { RETURN_EXPR (processString ()); } "out" { return (processSpec (QOUT)); } "in" { return (processSpec (QIN)); } "partial" { return (processSpec (QPARTIAL)); } @@ -307,7 +310,9 @@ static void setTokLengthT (size_t len) "killed" { return (processSpec (QKILLED)); } "nullterminated" { return (processSpec (QNULLTERMINATED));} "MaxSet" { return (processSpec (QMAXSET));} -"MaxRead" { return (processSpec (QMAXREAD));} +"MaxRead" { return (processSpec (QMAXREAD));} +"maxSet" { return (processSpec (QMAXSET));} +"maxRead" { return (processSpec (QMAXREAD));} {Letter}({Letter}|{Digit})* { int tok; context_saveLocation (); @@ -584,11 +589,9 @@ struct skeyword s_parsetable[] = { { "releases", QRELEASES } , { "pre", QPRECLAUSE } , { "post", QPOSTCLAUSE } , - {"setBufferSize", QSETBUFFERSIZE}, - {"LRequires", QBUFFERCONSTRAINT}, - {"LEnsures", QENSURESCONSTRAINT}, - {"setStringLength", QSETSTRINGLENGTH}, - {"testinRange", QTESTINRANGE}, + { "setBufferSize", QSETBUFFERSIZE}, + { "setStringLength", QSETSTRINGLENGTH}, + { "testinRange", QTESTINRANGE}, { "requires", QPRECLAUSE } , { "ensures", QPOSTCLAUSE } , { NULL, BADTOK } @@ -635,8 +638,6 @@ struct skeyword s_keytable[] = { { "relnull", QRELNULL } , { "nullterminated", QNULLTERMINATED }, { "setBufferSize", QSETBUFFERSIZE }, - { "LRequires", QBUFFERCONSTRAINT }, - { "LEnsures", QENSURESCONSTRAINT }, { "testInRange", QTESTINRANGE}, { "MaxSet", QMAXSET}, { "MaxRead", QMAXREAD}, @@ -1311,7 +1312,7 @@ static bool processMacro (void) uentry_showWhereSpecified (e2); uentry_setType (e2, ctype_unknown); - uentry_makeVarFunction (e2); + uentry_makeConstantFunction (e2); uentry_setDefined (e2, g_currentloc); uentry_setFunctionDefined (e2, g_currentloc); context_enterUnknownMacro (e2); @@ -1999,20 +2000,22 @@ static int handleLlSpecial () } else { - llerror - (FLG_BADFLAG, + voptgenerror + (FLG_UNRECOGFLAGCOMMENTS, message ("Unrecognized option in semantic comment: %s", - flagname)); + flagname), + g_currentloc); } } else if (flagcode_isGlobalFlag (fflag)) { - llerror + voptgenerror (FLG_BADFLAG, message ("Semantic comment attempts to set global flag %s. " "A global flag cannot be set locally.", - flagname)); + flagname), + g_currentloc); } else { @@ -2022,12 +2025,13 @@ static int handleLlSpecial () { if (ynm_isMaybe (set)) { - llerror + voptgenerror (FLG_BADFLAG, message ("Semantic comment attempts to restore flag %s. " "A flag for setting a value cannot be restored.", - flagname)); + flagname), + g_currentloc); } else { /* cut-and-pastied from llmain...blecch */ @@ -2513,7 +2517,24 @@ static int processIdentifier (cstring id) } else { - annotationInfo ainfo = context_lookupAnnotation (id); + annotationInfo ainfo; + + if (expectingMetaStateName) + { + metaStateInfo msinfo = context_lookupMetaStateInfo (id); + + if (metaStateInfo_isDefined (msinfo)) + { + yylval.msinfo = msinfo; + return METASTATE_NAME; + } + else + { + DPRINTF (("Not meta state name: %s", cstring_toCharsSafe (id))); + } + } + + ainfo = context_lookupAnnotation (id); if (annotationInfo_isDefined (ainfo)) { @@ -2953,3 +2974,16 @@ processSpec (int tok) return (processIdentifier (makeIdentifier (yytext))); } } + +void cscanner_expectingMetaStateName () +{ + llassert (!expectingMetaStateName); + llassert (context_inFunctionHeader ()); + expectingMetaStateName = TRUE; +} + +void cscanner_clearExpectingMetaStateName () +{ + llassert (expectingMetaStateName); + expectingMetaStateName = FALSE; +}