static type OptionalQualifiers (type Q)
/* Read type qualifiers if we have any */
{
- while (curtok == TOK_CONST || curtok == TOK_VOLATILE) {
+ while (CurTok.Tok == TOK_CONST || CurTok.Tok == TOK_VOLATILE) {
- switch (curtok) {
+ switch (CurTok.Tok) {
case TOK_CONST:
if (Q & T_QUAL_CONST) {
static void optionalint (void)
/* Eat an optional "int" token */
{
- if (curtok == TOK_INT) {
+ if (CurTok.Tok == TOK_INT) {
/* Skip it */
NextToken ();
}
static void optionalsigned (void)
/* Eat an optional "signed" token */
{
- if (curtok == TOK_SIGNED) {
+ if (CurTok.Tok == TOK_SIGNED) {
/* Skip it */
NextToken ();
}
D->Flags &= ~DS_DEF_STORAGE;
/* Check the storage class given */
- switch (curtok) {
+ switch (CurTok.Tok) {
case TOK_EXTERN:
D->StorageClass = SC_EXTERN | SC_STATIC;
ident Ident;
/* Accept forward definitions */
- if (curtok != TOK_LCURLY) {
+ if (CurTok.Tok != TOK_LCURLY) {
return;
}
/* Read the enum tags */
EnumVal = 0;
- while (curtok != TOK_RCURLY) {
+ while (CurTok.Tok != TOK_RCURLY) {
/* We expect an identifier */
- if (curtok != TOK_IDENT) {
+ if (CurTok.Tok != TOK_IDENT) {
Error ("Identifier expected");
continue;
}
NextToken ();
/* Check for an assigned value */
- if (curtok == TOK_ASSIGN) {
+ if (CurTok.Tok == TOK_ASSIGN) {
struct expent lval;
NextToken ();
constexpr (&lval);
AddConstSym (Ident, type_int, SC_ENUM, EnumVal++);
/* Check for end of definition */
- if (curtok != TOK_COMMA)
+ if (CurTok.Tok != TOK_COMMA)
break;
NextToken ();
}
SymEntry* Entry;
- if (curtok != TOK_LCURLY) {
+ if (CurTok.Tok != TOK_LCURLY) {
/* Just a forward declaration. Try to find a struct with the given
* name. If there is none, insert a forward declaration into the
* current lexical level.
/* Parse struct fields */
Size = 0;
- while (curtok != TOK_RCURLY) {
+ while (CurTok.Tok != TOK_RCURLY) {
/* Get the type of the entry */
DeclSpec Spec;
}
}
- if (curtok != TOK_COMMA)
+ if (CurTok.Tok != TOK_COMMA)
break;
NextToken ();
}
Qualifiers = OptionalQualifiers (T_QUAL_NONE);
/* Look at the data type */
- switch (curtok) {
+ switch (CurTok.Tok) {
case TOK_VOID:
NextToken ();
case TOK_LONG:
NextToken ();
- if (curtok == TOK_UNSIGNED) {
+ if (CurTok.Tok == TOK_UNSIGNED) {
NextToken ();
optionalint ();
D->Type[0] = T_ULONG;
case TOK_SHORT:
NextToken ();
- if (curtok == TOK_UNSIGNED) {
+ if (CurTok.Tok == TOK_UNSIGNED) {
NextToken ();
optionalint ();
D->Type[0] = T_USHORT;
case TOK_SIGNED:
NextToken ();
- switch (curtok) {
+ switch (CurTok.Tok) {
case TOK_CHAR:
NextToken ();
case TOK_UNSIGNED:
NextToken ();
- switch (curtok) {
+ switch (CurTok.Tok) {
case TOK_CHAR:
NextToken ();
case TOK_STRUCT:
case TOK_UNION:
- StructType = (curtok == TOK_STRUCT)? T_STRUCT : T_UNION;
+ StructType = (CurTok.Tok == TOK_STRUCT)? T_STRUCT : T_UNION;
NextToken ();
/* */
- if (curtok == TOK_IDENT) {
+ if (CurTok.Tok == TOK_IDENT) {
strcpy (Ident, CurTok.Ident);
NextToken ();
} else {
case TOK_ENUM:
NextToken ();
- if (curtok != TOK_LCURLY) {
+ if (CurTok.Tok != TOK_LCURLY) {
/* Named enum */
- if (curtok == TOK_IDENT) {
+ if (CurTok.Tok == TOK_IDENT) {
/* Find an entry with this name */
Entry = FindTagSym (CurTok.Ident);
if (Entry) {
/* Parse an old style (K&R) parameter list */
{
/* Parse params */
- while (curtok != TOK_RPAREN) {
+ while (CurTok.Tok != TOK_RPAREN) {
/* List of identifiers expected */
- if (curtok != TOK_IDENT) {
+ if (CurTok.Tok != TOK_IDENT) {
Error ("Identifier expected");
}
NextToken ();
/* Check for more parameters */
- if (curtok == TOK_COMMA) {
+ if (CurTok.Tok == TOK_COMMA) {
NextToken ();
} else {
break;
ConsumeRParen ();
/* An optional list of type specifications follows */
- while (curtok != TOK_LCURLY) {
+ while (CurTok.Tok != TOK_LCURLY) {
DeclSpec Spec;
}
}
- if (curtok == TOK_COMMA) {
+ if (CurTok.Tok == TOK_COMMA) {
NextToken ();
} else {
break;
/* Parse a new style (ANSI) parameter list */
{
/* Parse params */
- while (curtok != TOK_RPAREN) {
+ while (CurTok.Tok != TOK_RPAREN) {
DeclSpec Spec;
Declaration Decl;
DeclAttr Attr;
/* Allow an ellipsis as last parameter */
- if (curtok == TOK_ELLIPSIS) {
+ if (CurTok.Tok == TOK_ELLIPSIS) {
NextToken ();
F->Flags |= FD_VARIADIC;
break;
++F->ParamCount;
/* Check for more parameters */
- if (curtok == TOK_COMMA) {
+ if (CurTok.Tok == TOK_COMMA) {
NextToken ();
} else {
break;
ConsumeRParen ();
/* Check if this is a function definition */
- if (curtok == TOK_LCURLY) {
+ if (CurTok.Tok == TOK_LCURLY) {
/* Print an error if in strict ANSI mode and we have unnamed
* parameters.
*/
EnterFunctionLevel ();
/* Check for several special parameter lists */
- if (curtok == TOK_RPAREN) {
+ if (CurTok.Tok == TOK_RPAREN) {
/* Parameter list is empty */
F->Flags |= (FD_EMPTY | FD_VARIADIC);
- } else if (curtok == TOK_VOID && nxttok == TOK_RPAREN) {
+ } else if (CurTok.Tok == TOK_VOID && NextTok.Tok == TOK_RPAREN) {
/* Parameter list declared as void */
NextToken ();
F->Flags |= FD_VOID_PARAM;
- } else if (curtok == TOK_IDENT && (nxttok == TOK_COMMA || nxttok == TOK_RPAREN)) {
+ } else if (CurTok.Tok == TOK_IDENT &&
+ (NextTok.Tok == TOK_COMMA || NextTok.Tok == TOK_RPAREN)) {
/* If the identifier is a typedef, we have a new style parameter list,
* if it's some other identifier, it's an old style parameter list.
*/
/* Recursively process declarators. Build a type array in reverse order. */
{
- if (curtok == TOK_STAR) {
+ if (CurTok.Tok == TOK_STAR) {
type T = T_PTR;
NextToken ();
/* Allow optional const or volatile qualifiers */
Decl (D, Mode);
*D->T++ = T;
return;
- } else if (curtok == TOK_LPAREN) {
+ } else if (CurTok.Tok == TOK_LPAREN) {
NextToken ();
Decl (D, Mode);
ConsumeRParen ();
- } else if (curtok == TOK_FASTCALL) {
+ } else if (CurTok.Tok == TOK_FASTCALL) {
/* Remember the current type pointer */
type* T = D->T;
/* Skip the fastcall token */
*/
if (Mode == DM_NO_IDENT) {
D->Ident[0] = '\0';
- } else if (curtok == TOK_IDENT) {
+ } else if (CurTok.Tok == TOK_IDENT) {
strcpy (D->Ident, CurTok.Ident);
NextToken ();
} else {
}
}
- while (curtok == TOK_LBRACK || curtok == TOK_LPAREN) {
- if (curtok == TOK_LPAREN) {
+ while (CurTok.Tok == TOK_LBRACK || CurTok.Tok == TOK_LPAREN) {
+ if (CurTok.Tok == TOK_LPAREN) {
/* Function declaration */
FuncDesc* F;
NextToken ();
unsigned long Size = 0;
NextToken ();
/* Read the size if it is given */
- if (curtok != TOK_RBRACK) {
+ if (CurTok.Tok != TOK_RBRACK) {
struct expent lval;
constexpr (&lval);
Size = lval.e_const;
}
- if (curtok != TOK_COMMA) {
+ if (CurTok.Tok != TOK_COMMA) {
break;
}
NextToken ();
- } while (curtok != TOK_RCURLY);
+ } while (CurTok.Tok != TOK_RCURLY);
ConsumeRCurly ();
}
/* Get a pointer to the list of symbols */
Entry = Tab->SymHead;
- while (curtok != TOK_RCURLY) {
+ while (CurTok.Tok != TOK_RCURLY) {
if (Entry == 0) {
Error ("Too many initializers");
return;
}
ParseInit (Entry->Type);
Entry = Entry->NextSym;
- if (curtok != TOK_COMMA)
+ if (CurTok.Tok != TOK_COMMA)
break;
NextToken ();
}
case T_ARRAY:
Size = Decode (T + 1);
t = T + DECODE_SIZE + 1;
- if (IsTypeChar(t) && curtok == TOK_SCONST) {
- str = GetLiteral (curval);
+ if (IsTypeChar(t) && CurTok.Tok == TOK_SCONST) {
+ str = GetLiteral (CurTok.IVal);
Count = strlen (str) + 1;
- TranslateLiteralPool (curval); /* Translate into target charset */
+ TranslateLiteralPool (CurTok.IVal); /* Translate into target charset */
g_defbytes (str, Count);
- ResetLiteralPoolOffs (curval); /* Remove string from pool */
+ ResetLiteralPoolOffs (CurTok.IVal); /* Remove string from pool */
NextToken ();
} else {
ConsumeLCurly ();
Count = 0;
- while (curtok != TOK_RCURLY) {
+ while (CurTok.Tok != TOK_RCURLY) {
ParseInit (T + DECODE_SIZE + 1);
++Count;
- if (curtok != TOK_COMMA)
+ if (CurTok.Tok != TOK_COMMA)
break;
NextToken ();
}