-
- while (((c = *ptr) != '\0') && !isspace (c))
- {
- len++;
-
- if (len > MAX_PRAGMA_LEN)
- {
- break;
- }
-
- ptr++;
- *pname++ = c;
- }
-
- *pname = '\0';
-
- if (len == PRAGMA_LEN_EXPAND
- && mstring_equal (opname, PRAGMA_EXPAND))
- {
- cstring exname = cstring_undefined;
- uentry ue;
-
- ptr++;
- while (((c = *ptr) != '\0') && !isspace (c))
- {
- exname = cstring_appendChar (exname, c);
- ptr++;
- }
-
-
- ue = usymtab_lookupExposeGlob (exname);
-
- if (uentry_isExpandedMacro (ue))
- {
- if (fileloc_isPreproc (uentry_whereDefined (ue)))
- {
- fileloc_setColumn (g_currentloc, 1);
- uentry_setDefined (ue, g_currentloc);
- }
- }
-
- cstring_free (exname);
- }
- }
- else if (cstring_equalPrefixLit (olc, "ident"))
- {
- /* Some pre-processors will leave these in the code. Ignore rest of line */
- }
- /*
- ** Yuk...Win32 filenames can have spaces in them...we need to read
- ** to the matching end quote.
- */
- else if ((sscanf (ol, "line %d \"", &lineno) == 1)
- || (sscanf (ol, " %d \"", &lineno) == 1))
- {
- char *tmp = ol;
- cstring fname;
- fileId fid;
-
- /*@access cstring@*/
- while (*tmp != '\"' && *tmp != '\0')
- {
- tmp++;
- }
-
- llassert (*tmp == '\"');
-
- tmp++;
-
- fname = tmp;
-
- while (*tmp != '\"' && *tmp != '\0')
- {
- tmp++;
- }
-
- llassert (*tmp == '\"');
-
- *tmp = '\0';
-
-# if defined(OS2) || defined(MSDOS) || defined(WIN32)
-
- /*
- ** DOS-like path delimiters get delivered in pairs, something like
- ** \"..\\\\file.h\", so we have to make it normal again. We do NOT
- ** remove the pre dirs yet as we usually specify tmp paths relative
- ** to the current directory, so tmp files would not get found in
- ** the hash table. If this method fails we try it again later.
- */
-
- {
- char *stmp = fname;
-
- /*
- ** Skip past the drive marker.
- */
-
- if (strchr (stmp, ':') != NULL)
- {
- stmp = strchr (stmp, ':') + 1;
- }
-
- while ((stmp = strchr (stmp, CONNECTCHAR)) != NULL )
- {
- if (*(stmp+1) == CONNECTCHAR)
- {
- memmove (stmp, stmp+1, strlen (stmp));
- }
-
- stmp++;
- }
-
- fid = fileTable_lookupBase (context_fileTable (), fname);
- if (!(fileId_isValid (fid)))
- {
- fname = removePreDirs (fname);
- fid = fileTable_lookupBase (context_fileTable (), fname);
- }
- }
-# else /* !defined(OS2) && !defined(MSDOS) */
- fname = removePreDirs (fname);
- fid = fileTable_lookupBase (context_fileTable (), fname);
-# endif /* !defined(OS2) && !defined(MSDOS) */
-
- if (!(fileId_isValid (fid)))
- {
- if (context_inXHFile ())
- {
- fid = fileTable_addXHFile (context_fileTable (), fname);
- }
- else if (isHeaderFile (fname))
- {
- fid = fileTable_addHeaderFile (context_fileTable (), fname);
- }
- else
- {
- fid = fileTable_addFile (context_fileTable (), fname);
- }
- }
-
- setFileLine (fid, lineno);
- /*@noaccess cstring@*/
- }
- else if ((sscanf (ol, "line %d", &lineno) == 1)
- || (sscanf (ol, " %d", &lineno) == 1))
- {
- setLine (lineno); /* next line is <cr> */
- }
- else
- {
- if (mstring_equal (ol, "")) {
- DPRINTF (("Empty pp command!"));
- /*
- ** evs 2000-05-16: This is a horrible kludge, to get around a bug (well, difficulty) in the pre-processor.
- ** We handle a plain # in the input file, by echoing it, and ignoring it in the post-pp-file.
- */
- mstring_free (ol);
- return FALSE;
- } else {
- voptgenerror
- (FLG_UNRECOGDIRECTIVE,
- message ("Unrecognized pre-processor directive: #%s",
- cstring_fromChars (ol)),
- g_currentloc);
- }
-
- sfree (ol);
- return FALSE; /* evans 2001-12-30: was: TRUE; */
- }
-
- sfree (ol);
- return FALSE;
-}
-
-static int handleLlSpecial ()
-{
- bool hasnl = FALSE;
- int ic;
- char c;
- char *s = mstring_createEmpty ();
- char *os;
- int tok;
- int charsread = 0;
- fileloc loc;
-
- loc = fileloc_copy (g_currentloc);
- DPRINTF (("Handle special: %s", fileloc_unparse (loc)));
-
- while (((ic = ninput ()) != 0) && isalpha (ic))
- {
- c = (char) ic;
- s = mstring_append (s, c);
- charsread++;
- }
-
- DPRINTF (("Read: %s / %s", s, fileloc_unparse (g_currentloc)));
- os = s;
-
- if (charsread == 0 && ic == (int) AFTER_COMMENT_MARKER[0])
- {
- ic = ninput ();
-
- llassert (ic == AFTER_COMMENT_MARKER[1]);
-
- if (*s == '\0')
- {
- sfree (os);
- fileloc_free (loc);
- return QNOMODS; /* special token no modifications token */
- }
- }
-
- DPRINTF (("Coment marker: %s", os));
- tok = commentMarkerToken (cstring_fromChars (os));
-
- if (tok != BADTOK)
- {
- tokLength = charsread;
- sfree (os);
- inSpecPart = TRUE;
- fileloc_free (loc);
- return tok;
- }
-
- DPRINTF (("Not a comment marker..."));
- /* Add rest of the comment */
-
- if (ic != 0 && ic != EOF)
- {
- c = (char) ic;
-
- s = mstring_append (s, c);
- charsread++;
-
- while (((ic = ninput ()) != 0) && (ic != EOF)
- && (ic != AFTER_COMMENT_MARKER[0]))
- {
- c = (char) ic;
-
- /* evans 2001-09-01 added to prevent assertion failures for uncloses syntactic comments */
-
- if (c == '\n') {
- hasnl = TRUE; /* This prevents tokLength from being set later. */
- tokLength = 0;
-
- voptgenerror
- (FLG_SYNTAX,
- message ("Likely parse error: syntactic comment token spans multiple lines: %s",
- cstring_fromChars (s)),
- g_currentloc);
- }
-
- s = mstring_append (s, c);
- charsread++;
- }
- }
-
- DPRINTF (("Read: %s / %s", s, fileloc_unparse (g_currentloc)));
-
- if (ic == AFTER_COMMENT_MARKER[0])
- {
- int nc = ninput ();
- llassert ((char) nc == AFTER_COMMENT_MARKER[1]);
- charsread++;
- }
-
- os = s;
-
- while (*s == ' ' || *s == '\t' || *s == '\n')
- {
- s++;
- }
-
- if (*s == '-' || *s == '+' || *s == '=') /* setting flags */
- {
- c = *s;
-
- while (c == '-' || c == '+' || c == '=')
- {
- ynm set = ynm_fromCodeChar (c);
- cstring thisflag;
-
- s++;
-
- thisflag = cstring_fromChars (s);
-
- while ((c = *s) != '\0' && (c != '-') && (c != '=')
- && (c != '+') && (c != ' ') && (c != '\t') && (c != '\n'))
- {
- s++;
- }
-
- *s = '\0';
-
- if (!context_getFlag (FLG_NOCOMMENTS))
- {
- cstring flagname = thisflag;
- flagcode fflag = flags_identifyFlag (flagname);
-
- if (flagcode_isSkip (fflag))
- {
- ;
- }
- else if (flagcode_isInvalid (fflag))
- {
- if (isMode (flagname))
- {
- if (ynm_isMaybe (set))
- {
- llerror
- (FLG_BADFLAG,
- message
- ("Semantic comment attempts to restore flag %s. "
- "A mode flag cannot be restored.",
- flagname));
- }
- else
- {
- context_setMode (flagname);
- }
- }
- else
- {
- voptgenerror
- (FLG_UNRECOGFLAGCOMMENTS,
- message ("Unrecognized option in semantic comment: %s",
- flagname),
- g_currentloc);
- }
- }
- else if (flagcode_isGlobalFlag (fflag))
- {
- voptgenerror
- (FLG_BADFLAG,
- message
- ("Semantic comment attempts to set global flag %s. "
- "A global flag cannot be set locally.",
- flagname),
- g_currentloc);
- }
- else
- {
- context_fileSetFlag (fflag, set);
-
- if (flagcode_hasArgument (fflag))
- {
- if (ynm_isMaybe (set))
- {
- voptgenerror
- (FLG_BADFLAG,
- message
- ("Semantic comment attempts to restore flag %s. "
- "A flag for setting a value cannot be restored.",
- flagname),
- g_currentloc);
- }
- else
- { /* cut-and-pastied from llmain...blecch */
- cstring extra = cstring_undefined;
- char *rest;
- char *orest;
- char rchar;
-
- *s = c;
- rest = mstring_copy (s);
- orest = rest;
- *s = '\0';
-
- while ((rchar = *rest) != '\0'
- && (isspace (rchar)))
- {
- rest++;
- s++;
- }
-
- while ((rchar = *rest) != '\0'
- && !isspace (rchar))
- {
- extra = cstring_appendChar (extra, rchar);
- rest++;
- s++;
- }
-
- sfree (orest);
-
- if (cstring_isUndefined (extra))
- {
- llerror
- (FLG_BADFLAG,
- message
- ("Flag %s (in semantic comment) must be followed by an argument",
- flagcode_unparse (fflag)));
- }
- else
- {
- s--;
-
- if (flagcode_hasNumber (fflag))
- {
- setValueFlag (fflag, extra);
- }
- else if (flagcode_hasChar (fflag))
- {
- setValueFlag (fflag, extra);
- }
- else if (flagcode_hasString (fflag))
- {
- setStringFlag (fflag, extra);
- }
- else
- {
- BADEXIT;
- }
- }
- }
- }
- }
- }
- else
- {
- ;
- }
-
- *s = c;
- while ((c == ' ') || (c == '\t') || (c == '\n'))
- {
- c = *(++s);
- }
- }
-
- if (context_inHeader () && !isArtificial (cstring_fromChars (os)))
- {
- DPRINTF (("Here adding comment: %s", os));
- context_addComment (cstring_fromCharsNew (os));
- }
- else
- {
- ;
- }
- }
- else
- {
- char *t = s;
- int macrocode;
- char tchar = '\0';
- annotationInfo ainfo;
-
- while (*s != '\0' && *s != ' ' && *s != '\t' && *s != '\n')
- {
- s++;
- }
-
- if (*s != '\0')
- {
- tchar = *s;
- *s = '\0';
- s++;
- }
-
- t = cstring_toCharsSafe (cstring_downcase (cstring_fromChars (t)));
- macrocode = tokenMacroCode (cstring_fromChars (t));
-
- if (macrocode != BADTOK)
- {
- tokLength = hasnl ? 0 : mstring_length (t);
-
- sfree (t);
- sfree (os);
- fileloc_free (loc);
-
- if (macrocode == SKIPTOK)
- {
- return BADTOK;
- }
-
- return macrocode;
- }
-
- ainfo = context_lookupAnnotation (cstring_fromChars (os));
-
- if (annotationInfo_isDefined (ainfo)) {
- DPRINTF (("Found annotation: %s", annotationInfo_unparse (ainfo)));
- /*@i324@*/ yylval.annotation = ainfo;
- tokLength = 0;
- sfree (os);
- sfree (t);
- fileloc_free (loc);
- return CANNOTATION;
- }
-
- if (context_inHeader ())
- {
- if (tchar != '\0')
- {
- *(s-1) = tchar;
- }
-
- if ((context_inMacro () || context_inGlobalContext ())
- && macrocode != SKIPTOK
- && !isArtificial (cstring_fromChars (os)))
- {
- DPRINTF (("Add comment: %s", os));
- context_addComment (cstring_fromCharsNew (os));
- }
- else
- {
- ;
- }
-
- if (tchar != '\0')
- {
- *(s-1) = '\0';
- }
- }
-
- if (mstring_equal (t, "ignore"))
- {
- if (!context_getFlag (FLG_NOCOMMENTS))
- {
- context_enterSuppressRegion ();
- }
- }
- else if ((*t == 'i' || *t == 't')
- && (*(t + 1) == '\0'))
- {
- if (!context_getFlag (FLG_NOCOMMENTS)
- && (*t == 'i' || context_getFlag (FLG_TMPCOMMENTS)))
- {
- context_enterSuppressLine (-1); /* infinite suppression */
- }
- }
- else if (((*t == 'i') || (*t == 't'))
- && ((*(t + 1) >= '0' && *(t + 1) <= '9')))
- {
- bool tmpcomment = (*t == 't');
- int val = -1;
- char *tt = t; /* don't mangle t, since it is free'd */
- char lc = *(++tt);
-
- if (lc >= '0' && lc <= '9')
- {
- val = (int)(lc - '0');
-
- lc = *(++tt);
- while (lc >= '0' && lc <= '9')
- {
- val *= 10;
- val += lc - '0';
- lc = *(++tt);
- }
- }
-
-
- if (!context_getFlag (FLG_NOCOMMENTS)
- && (!tmpcomment || context_getFlag (FLG_TMPCOMMENTS)))
- {
- context_enterSuppressLine (val);
- }
- }
- else if (mstring_equal (t, "end"))
- {
- if (!context_getFlag (FLG_NOCOMMENTS))
- {
- context_exitSuppressRegion ();
- }
- }
- else if (mstring_equal (t, "notfunction"))
- {
- ; /* handled by pcpp */
- }
- else if (mstring_equal (t, "access"))
- {
- cstring tname;
-
- while (TRUE)
- {
- while ((c = *s) && (c == ' ' || c == '\t' || c == '\n'))
- {
- s++;
- }
-
- if (c == '\0')
- {
- break;
- }
-
- tname = cstring_fromChars (s);
-
- while ((c = *s) != '\0' && c != ' '
- && c != '\t' && c != '\n' && c != ',')
- {
- s++;
- }
-
- *s = '\0';
-
- DPRINTF (("Access %s", tname));
-
- if (!context_getFlag (FLG_NOCOMMENTS)
- && !context_getFlag (FLG_NOACCESS))
- {
- if (usymtab_existsType (tname))
- {
- typeId uid = usymtab_getTypeId (tname);
- uentry ue = usymtab_getTypeEntry (uid);
-
- if (uentry_isAbstractDatatype (ue))
- {
- context_addFileAccessType (uid);
- DPRINTF (("Adding access to: %s / %d", tname, uid));
- }
- else
- {
- voptgenerror
- (FLG_COMMENTERROR,
- message
- ("Non-abstract type %s used in access comment",
- tname),
- g_currentloc);
- }
- }
- else
- {
- if (!(context_inSuppressRegion ()
- || context_inSuppressZone (g_currentloc)))
- {
- voptgenerror
- (FLG_COMMENTERROR,
- message
- ("Unrecognized type %s used in access comment",
- tname),
- g_currentloc);
- }
- }
- }
-
- if (c != '\0')
- {
- s++;
- }
-
- if (c != ',' && c != ' ')
- {
- break;
- }
- }
- }
- else if (mstring_equal (t, "noaccess"))
- {
- cstring tname;
- char lc;
-
- while (TRUE)
- {
- while ((lc = *s) && (lc == ' ' || lc == '\t' || lc == '\n'))
- {
- s++;
- }
-
- if (lc == '\0')
- {
- break;
- }
-
- tname = cstring_fromChars (s);
-
- while ((lc = *s) != '\0' && lc != ' ' && lc != '\t'
- && lc != '\n' && lc != ',')
- {
- s++;
- }
-
- *s = '\0';
-
- if (!context_getFlag (FLG_NOCOMMENTS)
- && !context_getFlag (FLG_NOACCESS))
- {
- if (usymtab_existsType (tname))
- {
- typeId tuid = usymtab_getTypeId (tname);
-
- if (context_couldHaveAccess (tuid))
- {
- DPRINTF (("Removing access: %s", tname));
- context_removeFileAccessType (tuid);
- }
- else
- {
- if (!(context_inSuppressRegion ()
- || context_inSuppressZone (g_currentloc)))
- {
- uentry ue = usymtab_getTypeEntry (tuid);
-
- if (uentry_isAbstractDatatype (ue))
- {
- voptgenerror
- (FLG_COMMENTERROR,
- message
- ("Non-accessible abstract type %s used in noaccess comment",
- tname),
- g_currentloc);
- }
- else
- {
- voptgenerror
- (FLG_COMMENTERROR,
- message
- ("Non-abstract type %s used in noaccess comment",
- tname),
- g_currentloc);
- }
- }
- }
- }
- else
- {
- if (!(context_inSuppressRegion ()
- || context_inSuppressZone (g_currentloc)))
- {
- voptgenerror
- (FLG_COMMENTERROR,
- message
- ("Unrecognized type %s used in noaccess comment",
- tname),
- g_currentloc);
- }
- }
- }
-
- if (lc != '\0')
- {
- s++;
- }
-
- if (lc != ',' && lc != ' ')
- {
- break;
- }
- }
- }
- else
- {
- voptgenerror (FLG_UNRECOGCOMMENTS,
- message ("Semantic comment unrecognized: %s",
- cstring_fromChars (os)), loc);
- }
-
- sfree (t);
- }
-
- sfree (os);
- fileloc_free (loc);
- return BADTOK;
-}
-
-static /*@only@*/ cstring makeIdentifier (char *s)
-{
- char *c = mstring_create (size_toInt (strlen (s)) + 1);
- cstring id = cstring_fromChars (c);
-
- while (isalnum (*s) || (*s == '_') || (*s == '$'))
- {
- *c++ = *s++;
- }
-
- *c = '\0';
- return (id);
-}
-
-/*@observer@*/ /*@dependent@*/ uentry coerceId (cstring cn)
-{
- if (!(usymtab_exists (cn)))
- {
- fileloc loc = fileloc_createExternal ();
-
- /*
- ** We need to put this in a global scope, otherwise the sRef will be deallocated.
- */
-
- uentry ce = uentry_makeUnrecognized (cn, loc);
-
- if (!context_inIterEnd ())
- {
- voptgenerror
- (FLG_SYSTEMUNRECOG,
- message ("Unrecognized (possibly system) identifier: %q",
- uentry_getName (ce)),
- g_currentloc);
- }
-
- return ce;
- }
-
- return (usymtab_lookup (cn));
-}
-
-/*
-** like, coerceId, but doesn't supercede for iters
-*/
-
-/*@observer@*/ uentry coerceIterId (cstring cn)
-{
- if (!(usymtab_exists (cn)))
- {
- return uentry_undefined;
- }
-
- return (usymtab_lookup (cn));
-}
-
-/*@observer@*/ cstring LastIdentifier ()
-{
- return (lastidprocessed);
-}
-
-static int processIdentifier (cstring id)
-{
- uentry le;
-
- if (context_getFlag (FLG_GRAMMAR))
- {
- lldiagmsg (message ("Process identifier: %s", id));
- }
-
- context_clearJustPopped ();
- lastidprocessed = id;
-
- if (context_inFunctionHeader ())
- {
- int tok = commentMarkerToken (id);
- DPRINTF (("in function decl..."));
-
- if (tok != BADTOK)
- {
- return tok;
- }
- else
- {
- tok = tokenMacroCode (id);
-
- if (tok != BADTOK)
- {
- return tok;
- }
- else
- {
- 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))
- {
- DPRINTF (("Found annotation: %s", annotationInfo_unparse (ainfo)));
- /*@i324@*/ yylval.annotation = ainfo;
- return CANNOTATION;
- }
- else
- {
- DPRINTF (("Not annotation: %s", id));
- }
- }
- }
- }
-
- /* Consider handling: Defined by C99 as static const char __func__[] */
-
- if (context_getFlag (FLG_GNUEXTENSIONS))
- {
- int tok = BADTOK;
-
- if (cstring_equalLit (id, "__stdcall")
- || cstring_equalLit (id, "__cdecl")
- || cstring_equalLit (id, "__extension__"))
- {
- return BADTOK;
- }
- else if (cstring_equalLit (id, "__volatile__"))
- {
- tok = QVOLATILE;
- }
- else if (cstring_equalLit (id, "__signed"))
- {
- tok = QSIGNED;
- }
- else if (cstring_equalLit (id, "__unsigned"))
- {
- tok = QUNSIGNED;
- }
- else if (cstring_equalLit (id, "__const__"))
- {
- tok = QCONST;
- }
- else if (cstring_equalLit (id, "__alignof__"))
- {
- tok = CALIGNOF; /* alignof is parsed like sizeof */
- }
- else if (cstring_equalLit (id, "__FUNCTION__")
- || cstring_equalLit (id, "__PRETTY_FUNCTION__"))
- {
- /* These tokens hold the name of the current function as strings */
- /* evans 2001-12-30: changed from exprNode_stringLiteral; bug reported by Jim Zelenka. */
- yylval.expr = exprNode_makeConstantString (id, fileloc_copy (g_currentloc));
- tokLength = 0;
- lastWasString = TRUE;
- tok = CCONSTANT;
- return tok;
- }
- else if (cstring_equalLit (id, "__attribute__")
- || cstring_equalLit (id, "__asm__")
- || cstring_equalLit (id, "_asm")
- || cstring_equalLit (id, "__asm")
- || cstring_equalLit (id, "__declspec"))
- {
- int depth = 0;
- bool useparens = FALSE;
- bool usebraces = FALSE;
- bool inquote = FALSE;
- bool inescape = FALSE;
- int ic;
-
- while ((ic = input ()) != EOF)
- {
-
- if (inescape)
- {
- inescape = FALSE;
- }
- else if (ic == '\\')
- {
- inescape = TRUE;
- }
- else if (ic == '\"')
- {
- inquote = !inquote;
- }
- else if (!inquote)
- {
- if (ic == '(')
- {
- if (!useparens)
- {
- if (!usebraces)
- {
- useparens = TRUE;
- }
- }
-
- if (useparens)
- {
- depth++;
- }
- }
- else if (ic == '{')
- {
- if (!usebraces)
- {
- if (!useparens)
- {
- usebraces = TRUE;
- }
- }
-
- if (usebraces)
- {
- depth++;
- }
- }
- else if (ic == ')' && useparens)
- {
- depth--;
- if (depth == 0) break;
- }
- else if (ic == '}' && usebraces)
- {
- depth--;
- if (depth == 0) break;
- }
- else if (ic == '}'
- && !usebraces && !useparens
- && cstring_equalLit (id, "__asm"))
- {
- /*
- ** We need this because some MS VC++ include files
- ** have __asm mov ... }
- ** Its a kludge, but otherwise would need to parse
- ** the asm code!
- */
- return TRBRACE;
- }
- }
-
- if (ic == '\n')
- {
- context_incLineno ();
-
- if (cstring_equalLit (id, "__asm")
- && !useparens && !usebraces)
- {
- break;
- }
- }
- }
-
- llassert ((useparens && ic == ')')
- || (usebraces && ic == '}')
- || (!useparens && !usebraces));
-
- return BADTOK;
- }
- else if (cstring_equalLit (id, "inline")
- || cstring_equalLit (id, "__inline")
- || cstring_equalLit (id, "_inline")
- || cstring_equalLit (id, "__inline__"))
- {
- tok = QINLINE;
- }
-
- if (tok != BADTOK)
- {
- RETURN_TOK (tok);
- }
- }
-
- le = usymtab_lookupSafe (id);
-
- /*@-dependenttrans@*/
-
- if (uentry_isIter (le))
- {
- /*@i32@*/ yylval.entry = le;
- return (ITER_NAME);
- }
- else if (uentry_isEndIter (le))
- {
- /*@i32@*/ yylval.entry = le;
- return (ITER_ENDNAME);
- }
- else if (uentry_isUndefined (le))
- {
- yylval.cname = id;
-
- /* avoid parse errors for certain system built ins */
-
- if (g_expectingTypeName && (cstring_firstChar (id) == '_')
- && (cstring_secondChar (id) == '_'))
- {
- return (TYPE_NAME_OR_ID);
- }
-
- return (NEW_IDENTIFIER);
- }
- else if (!uentry_isDeclared (le) && !uentry_isCodeDefined (le))
- {
- if (uentry_isDatatype (le))
- {
- yylval.cname = id;
- return (NEW_IDENTIFIER);
- }
- else
- {
- /*@i32@*/ yylval.entry = le;
- return (IDENTIFIER);
- }
- }
- else if (uentry_isDatatype (le))
- {
- if (!g_expectingTypeName)
- {
- yylval.cname = id;
-
- return (NEW_IDENTIFIER);
- }
- else
- {
- yylval.ctyp = uentry_getAbstractType (le);
-
- uentry_setUsed (le, g_currentloc);
- return (TYPE_NAME);
- }
- }
- else
- {
- /*@i32@*/ yylval.entry = le;
- return (IDENTIFIER);
- }
-
- /*@=dependenttrans@*/
-}
-
-static bool processHashIdentifier (/*@only@*/ cstring id)
-{
- if (context_inMacro () || context_inIterDef () ||
- context_inIterEnd ())
- {
- uentry le;
-
- context_clearJustPopped ();
-
- lastidprocessed = id;
- le = usymtab_lookupSafe (id);
-
- if (uentry_isParam (le) || uentry_isRefParam (le))
- {
- return TRUE;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- /*
- ** Will be handled by handleLlSpecial
- */
-
- cstring_free (id);
- return FALSE;
- }
-}
-
-
-static /*@only@*/ exprNode processString ()
-{
- exprNode res;
- fileloc loc;
- char *nl = strchr (yytext, '\n');
- cstring ns = cstring_fromCharsNew (yytext);
-
- if (nl == NULL)
- {
- loc = fileloc_copy (g_currentloc);
- addColumn (cstring_length (ns));
- }
- else
- {
- char *lastnl = nl;
-
- loc = fileloc_copy (g_currentloc);
-
- context_incLineno ();
-
- while ((nl = strchr ((nl + 1), '\n')) != NULL)
- {
- context_incLineno ();
- lastnl = nl;
- }
- }
-
-
- res = exprNode_stringLiteral (ns, loc);
- return (res);
-}
-
-/*
-** process a wide character string L"...."
-*/
-
-static /*@only@*/ exprNode processWideString ()
-{
- exprNode res;
- fileloc loc;
- char *nl = strchr (yytext, '\n');
- cstring ns;
-
- llassert (*yytext == 'L');
- yytext++;
-
- ns = cstring_fromCharsNew (yytext);
-
- if (nl == NULL)
- {
- loc = fileloc_copy (g_currentloc);
- addColumn (cstring_length (ns));
- }
- else
- {
- char *lastnl = nl;
-
- loc = fileloc_copy (g_currentloc);
-
- context_incLineno ();
-
- while ((nl = strchr ((nl + 1), '\n')) != NULL)
- {
- context_incLineno ();
- lastnl = nl;
- }
- }
-
- res = exprNode_wideStringLiteral (ns, loc);
- return (res);
-}
-
-static
-char processChar ()
-{
- char fchar;
- char next;
-
- llassert (*yytext != '\0');
- fchar = *(yytext + 1);
- if (fchar != '\\') return fchar;
-
- next = *(yytext + 2);
-
- switch (next)
- {
- case 'n': return '\n';
- case 't': return '\t';
- case '\"': return '\"';
- case '\'': return '\'';
- case '\\': return '\\';
- default: return '\0';
- }
-}
-
-static
-double processFloat ()
-{
- double ret = atof (yytext);
-
- return (ret);
-}
-
-static
-long processHex ()
-{
- int index = 2;
- long val = 0;
-
- llassert (yytext[0] == '0'
- && (yytext[1] == 'X' || yytext[1] == 'x'));
-
- while (yytext[index] != '\0') {
- int tval;
- char c = yytext[index];
-
- if (c >= '0' && c <= '9') {
- tval = (int) c - (int) '0';
- } else if (c >= 'A' && c <= 'F') {
- tval = (int) c - (int) 'A' + 10;
- } else if (c >= 'a' && c <= 'f') {
- tval = (int) c - (int) 'a' + 10;
- } else if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
- index++;
- while (yytext[index] != '\0') {
- if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
- ;
- } else {
- voptgenerror
- (FLG_SYNTAX,
- message ("Invalid character (%c) following specifier in hex constant: %s",
- c, cstring_fromChars (yytext)),
- g_currentloc);
- }
- index++;
- }
-
- break;
- } else {
- voptgenerror
- (FLG_SYNTAX,
- message ("Invalid character (%c) in hex constant: %s",
- c, cstring_fromChars (yytext)),
- g_currentloc);
- break;
- }
-
- val = (val * 16) + tval;
- index++;
- }
-
- DPRINTF (("Hex constant: %s = %ld", yytext, val));
- return val;
-}
-
-static
-long processOctal ()
-{
- int index = 1;
- long val = 0;
-
- llassert (yytext[0] == '0' && yytext[1] != 'X' && yytext[1] != 'x');
-
- while (yytext[index] != '\0') {
- int tval;
- char c = yytext[index];
-
- if (c >= '0' && c <= '7') {
- tval = (int) c - (int) '0';
- } else if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
- index++;
- while (yytext[index] != '\0') {
- if (c == 'U' || c == 'L' || c == 'u' || c == 'l') {
- ;
- } else {
- voptgenerror
- (FLG_SYNTAX,
- message ("Invalid character (%c) following specifier in octal constant: %s",
- c, cstring_fromChars (yytext)),
- g_currentloc);
- }
- index++;
- }
-
- break;
- } else {
- voptgenerror
- (FLG_SYNTAX,
- message ("Invalid character (%c) in octal constant: %s",
- c, cstring_fromChars (yytext)),
- g_currentloc);
- break;
- }
-
- val = (val * 8) + tval;
- index++;
- }
-
- DPRINTF (("Octal constant: %s = %ld", yytext, val));
- return val;
-}
-
-static
-long processDec ()
-{
- return (atol (yytext));
-}
-
-static int
-processSpec (int tok)
-{
- size_t length = strlen (yytext);
-
- if (inSpecPart)
- {
- setTokLengthT (length);
- RETURN_TOK (tok);
- }
- else
- {
-
- context_saveLocation ();
- setTokLengthT (length);
- return (processIdentifier (makeIdentifier (yytext)));
- }
-}
-
-void cscanner_expectingMetaStateName ()
-{
- llassert (!expectingMetaStateName);
- llassert (context_inFunctionHeader ());
- expectingMetaStateName = TRUE;
-}
-
-void cscanner_clearExpectingMetaStateName ()
-{
- llassert (expectingMetaStateName);
- expectingMetaStateName = FALSE;
-}