本文整理汇总了C++中NextToken函数的典型用法代码示例。如果您正苦于以下问题:C++ NextToken函数的具体用法?C++ NextToken怎么用?C++ NextToken使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NextToken函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: SAFE_RELEASE
HRESULT CMixerControl::LoadControl(XMLEl* pLibrary)
{
XMLEl* pThis = 0;
CCString sValues;
PCWSTR wszCurrent = 0;// Current place in the sValues string.
WCHAR* wszToken = 0;// The token. To avoid a buffer-overrun we make this string the same size as sValues.
int i = 0;// Current index we're workin on.
MIXERCONTROLDETAILS_BOOLEAN* pBoolean = (MIXERCONTROLDETAILS_BOOLEAN*)m_pRaw;
MIXERCONTROLDETAILS_UNSIGNED* pUnsigned = (MIXERCONTROLDETAILS_UNSIGNED*)m_pRaw;
MIXERCONTROLDETAILS_SIGNED* pSigned = (MIXERCONTROLDETAILS_SIGNED*)m_pRaw;
if(FAILED(GetNode(0, pLibrary, &pThis, FALSE)))
{
return MIX_E_XMLERR;
}
// Here, we concern ourself with the value attribute.
if(FAILED(XMLGetAttribute(pThis, CCString(L"Values"), &sValues)))
{
SAFE_RELEASE(pThis);
return MIX_E_XMLERR;
}
// Let's go case-insensitive.
sValues.upr();
// If we're doing raw binary data, we can skip all the parsing.
if(m_DataType == MIXDT_CUSTOM)
{
sValues.ToBinary(m_pRaw, m_mc.Metrics.cbCustomData);
SAFE_RELEASE(pThis);
return S_OK;
}
// Set up our looping stuff.
wszCurrent = sValues;
wszToken = (WCHAR*)malloc((wcslen(wszCurrent)+1)*sizeof(WCHAR));
while(1)
{
wszCurrent = NextToken(wszToken, wszCurrent);
if(m_DataType == MIXDT_BOOLEAN)
{
// Now wszToken is the current token.
if(wcsicmp(wszToken, L"TRUE") == 0)
{
pBoolean[i].fValue = TRUE;
}
else if(wcsicmp(wszToken, L"FALSE") == 0)
{
pBoolean[i].fValue = FALSE;
}
}
else if(m_DataType == MIXDT_SIGNED)
{
pSigned[i].lValue = wcstol(wszToken, 0, 10);
}
else if(m_DataType == MIXDT_UNSIGNED)
{
pUnsigned[i].dwValue = wcstoul(wszToken, 0, 10);
}
i++;
if(i >= m_nRawItems) break;
if(wszCurrent == 0) break;
}
free(wszToken);
wszToken = 0;
SAFE_RELEASE(pThis);
// Now commit the buffer.
_CommitRawBuffer();
return S_OK;
}
开发者ID:thenfour,项目名称:Volumizer,代码行数:80,代码来源:MixerControl.cpp
示例2: ParseFunction
/*
* funcbody starts with the current symbol being either
* the first parameter id or the begin for the local
* block. If begin is the current symbol then funcbody
* assumes that the function has no parameters.
*/
int ParseFunction(SYM *sp)
{
int i;
SYM *sp1, *sp2, *pl, *osp;
Statement *stmt;
int nump;
__int16 *ta;
int nn;
std::string name;
dfs.puts("<ParseFunction>\n");
isFuncBody = true;
if (sp==NULL) {
fatal("Compiler error: ParseFunction: SYM is NULL\r\n");
}
dfs.printf("***********************************\n");
dfs.printf("***********************************\n");
dfs.printf("***********************************\n");
if (sp->parent)
dfs.printf("Parent: %s\n", (char *)sp->GetParentPtr()->name->c_str());
dfs.printf("Parsing function: %s\n", (char *)sp->name->c_str());
dfs.printf("***********************************\n");
dfs.printf("***********************************\n");
dfs.printf("***********************************\n");
sp->stkname = stkname;
if (verbose) printf("Parsing function: %s\r\n", (char *)sp->name->c_str());
nump = nparms;
iflevel = 0;
// There could be unnamed parameters in a function prototype.
dfs.printf("A");
// declare parameters
// Building a parameter list here allows both styles of parameter
// declarations. the original 'C' style is parsed here. Originally the
// parameter types appeared as list after the parenthesis and before the
// function body.
sp->BuildParameterList(&nump);
dfs.printf("B");
sp->mangledName = sp->BuildSignature(1); // build against parameters
// If the symbol has a parent then it must be a class
// method. Search the parent table(s) for matching
// signatures.
osp = sp;
name = *sp->name;
if (sp->parent) {
SYM *sp2;
dfs.printf("PArent Class:%s|",(char *)sp->GetParentPtr()->name->c_str());
sp2 = sp->GetParentPtr()->Find(name);
if (sp2) {
dfs.printf("Found at least inexact match");
sp2 = sp->FindExactMatch(TABLE::matchno);
}
if (sp2 == nullptr)
error(ERR_METHOD_NOTFOUND);
else
sp = sp2;
sp->PrintParameterTypes();
}
else {
if (gsyms[0].Find(name)) {
sp = TABLE::match[TABLE::matchno-1];
}
}
dfs.printf("C");
if (sp != osp) {
dfs.printf("ParseFunction: sp changed\n");
osp->params.CopyTo(&sp->params);
osp->proto.CopyTo(&sp->proto);
sp->derivitives = osp->derivitives;
sp->mangledName = osp->mangledName;
// Should free osp here. It's not needed anymore
}
if (lastst == closepa) {
NextToken();
}
dfs.printf("D");
if (sp->tp->type == bt_pointer) {
if (lastst==assign) {
doinit(sp);
}
sp->IsNocall = isNocall;
sp->IsPascal = isPascal;
sp->IsKernel = isKernel;
sp->IsInterrupt = isInterrupt;
sp->IsTask = isTask;
sp->NumParms = nump;
sp->IsVirtual = isVirtual;
isPascal = FALSE;
isKernel = FALSE;
isOscall = FALSE;
isInterrupt = FALSE;
isTask = FALSE;
isNocall = FALSE;
//.........这里部分代码省略.........
开发者ID:BigEd,项目名称:Cores,代码行数:101,代码来源:ParseFunction.cpp
示例3: ForStatement
static void ForStatement (void)
/* Handle a 'for' statement */
{
ExprDesc lval1;
ExprDesc lval3;
int HaveIncExpr;
CodeMark IncExprStart;
CodeMark IncExprEnd;
int PendingToken;
/* Get several local labels needed later */
unsigned TestLabel = GetLocalLabel ();
unsigned BreakLabel = GetLocalLabel ();
unsigned IncLabel = GetLocalLabel ();
unsigned BodyLabel = GetLocalLabel ();
/* Skip the FOR token */
NextToken ();
/* Add the loop to the loop stack. A continue jumps to the start of the
* the increment condition.
*/
AddLoop (BreakLabel, IncLabel);
/* Skip the opening paren */
ConsumeLParen ();
/* Parse the initializer expression */
if (CurTok.Tok != TOK_SEMI) {
Expression0 (&lval1);
}
ConsumeSemi ();
/* Label for the test expressions */
g_defcodelabel (TestLabel);
/* Parse the test expression */
if (CurTok.Tok != TOK_SEMI) {
Test (BodyLabel, 1);
g_jump (BreakLabel);
} else {
g_jump (BodyLabel);
}
ConsumeSemi ();
/* Remember the start of the increment expression */
GetCodePos (&IncExprStart);
/* Label for the increment expression */
g_defcodelabel (IncLabel);
/* Parse the increment expression */
HaveIncExpr = (CurTok.Tok != TOK_RPAREN);
if (HaveIncExpr) {
Expression0 (&lval3);
}
/* Jump to the test */
g_jump (TestLabel);
/* Remember the end of the increment expression */
GetCodePos (&IncExprEnd);
/* Skip the closing paren */
ConsumeRParen ();
/* Loop body */
g_defcodelabel (BodyLabel);
Statement (&PendingToken);
/* If we had an increment expression, move the code to the bottom of
* the loop. In this case we don't need to jump there at the end of
* the loop body.
*/
if (HaveIncExpr) {
CodeMark Here;
GetCodePos (&Here);
MoveCode (&IncExprStart, &IncExprEnd, &Here);
} else {
/* Jump back to the increment expression */
g_jump (IncLabel);
}
/* Skip a pending token if we have one */
SkipPending (PendingToken);
/* Declare the break label */
g_defcodelabel (BreakLabel);
/* Remove the loop from the loop stack */
DelLoop ();
}
开发者ID:Aliandrana,项目名称:snesdev,代码行数:92,代码来源:stmt.c
示例4: ParseFunction
/*
* funcbody starts with the current symbol being either
* the first parameter id or the begin for the local
* block. If begin is the current symbol then funcbody
* assumes that the function has no parameters.
*/
int ParseFunction(SYM *sp)
{
int poffset, i;
int oldglobal;
SYM *sp1, *sp2;
Statement *stmt;
if (sp==NULL) {
fatal("Compiler error: ParseFunction: SYM is NULL\r\n");
}
sp->stkname = stkname;
if (verbose) printf("Parsing function: %s\r\n", sp->name);
oldglobal = global_flag;
global_flag = 0;
poffset = 24; /* size of return block */
nparms = 0;
iflevel = 0;
// There could be unnamed parameters in a function prototype.
if(lastst == id || 1) { /* declare parameters */
//while(lastst == id) {
// names[nparms++] = litlate(lastid);
// NextToken();
// if( lastst == comma)
// NextToken();
// else
// break;
// }
//needpunc(closepa);
// dodecl(sc_member); /* declare parameters */
sp->parms = (SYM *)NULL;
ParseParameterDeclarations(1);
for(i = 0;i < nparms;++i) {
if( (sp1 = search(names[i],&lsyms)) == NULL)
sp1 = makeint(names[i]);
//if( sp1->tp->size < 8 )
//{
// sp1->value.i = poffset;// + (8 - sp1->tp->size);
// poffset += 8;
//}
//else
//{
// sp1->value.i = poffset;
// poffset += sp1->tp->size;
//}
sp1->value.i = poffset;
// Check for aggregate types passed as parameters. Structs
// and unions use the type size.
// if (sp1->tp->type==bt_struct || sp1->tp->type==bt_union) {
poffset += round8(sp1->tp->size);
if (round8(sp1->tp->size) > 8)
sp->IsLeaf = FALSE;
// }
// else
// poffset += 8;
//sp1->value.i = poffset;
//poffset += 8;
sp1->storage_class = sc_auto;
sp1->nextparm = (SYM *)NULL;
// record parameter list
if (sp->parms == (SYM *)NULL) {
sp->parms = sp1;
}
else {
sp1->nextparm = sp->parms;
sp->parms = sp1;
}
}
// Process extra hidden parameter
if (sp->tp->btp->type==bt_struct || sp->tp->btp->type==bt_union) {
sp1 = makeint(litlate("_pHiddenStructPtr"));
sp1->value.i = poffset;
poffset += 8;
sp1->storage_class = sc_auto;
sp1->nextparm = (SYM *)NULL;
// record parameter list
if (sp->parms == (SYM *)NULL) {
sp->parms = sp1;
}
else {
sp1->nextparm = sp->parms;
sp->parms = sp1;
}
nparms++;
}
}
if (lastst == closepa)
NextToken();
if (sp->tp->type == bt_pointer) {
if (lastst==assign) {
doinit(sp);
}
sp->IsNocall = isNocall;
sp->IsPascal = isPascal;
sp->IsKernel = isKernel;
//.........这里部分代码省略.........
开发者ID:BigEd,项目名称:Cores,代码行数:101,代码来源:ParseFunction.c
示例5: NextThenAcceptToken
//------------------------------------------------------------------------------
int NextThenAcceptToken(READFILE Stream,TokenType Type,char * Value) {
NextToken(Stream);
return(AcceptToken(Stream,Type,Value));
}
开发者ID:mihasighi,项目名称:smtcomp14-sl,代码行数:6,代码来源:Tokenizer.c
示例6: MenuMaker_ShowMenu
// show one of the root menus
bool MenuMaker_ShowMenu(int id, const char* param)
{
char buffer[MAX_PATH];
Menu *m;
int x, y, n, flags, toggle;
static const char * const menu_string_ids[] = {
"",
"root",
"workspaces",
"icons",
"tasks",
"configuration",
NULL
};
enum {
e_lastmenu,
e_root,
e_workspaces,
e_icons,
e_tasks,
e_configuration,
};
x = y = flags = n = toggle = 0;
switch (id)
{
case BB_MENU_BROAM: // @ShowMenu ...
while (param[0] == '-') {
const char *p = NextToken(buffer, ¶m, NULL);
if (0 == strcmp(p, "-at")) {
for (;;++param) {
if (*param == 'r')
flags |= BBMENU_XRIGHT;
else if (*param == 'b')
flags |= BBMENU_YBOTTOM;
else
break;
}
x = atoi(NextToken(buffer, ¶m, " ,"));
param += ',' == *param;
y = atoi(NextToken(buffer, ¶m, NULL));
flags |= BBMENU_XY;
} else if (0 == strcmp(p, "-key")) {
flags |= BBMENU_KBD;
} else if (0 == strcmp(p, "-toggle")) {
toggle = 1;
} else if (0 == strcmp(p, "-pinned")) {
flags |= BBMENU_PINNED;
} else if (0 == strcmp(p, "-ontop")) {
flags |= BBMENU_ONTOP;
} else if (0 == strcmp(p, "-notitle")) {
flags |= BBMENU_NOTITLE;
}
}
break;
case BB_MENU_ROOT: // Main menu
param = "root";
break;
case BB_MENU_TASKS: // Workspaces menu
param = "workspaces";
break;
case BB_MENU_ICONS: // Iconized tasks menu
param = "icons";
break;
case BB_MENU_UPDATE:
Menu_Update(MENU_UPD_ROOT);
Menu_All_Redraw(0);
return false;
case BB_MENU_SIGNAL: // just to signal e.g. BBSoundFX
return true;
default:
return false;
}
// If invoked by kbd and the menu currently has focus,
// hide it and return
if (((flags & BBMENU_KBD) || toggle) && Menu_ToggleCheck(param))
return false;
//DWORD t1 = GetTickCount();
switch (get_string_index(param, menu_string_ids))
{
case e_root:
case e_lastmenu:
m = MakeRootMenu("root", menuPath(NULL), default_root_menu, true);
break;
case e_workspaces:
m = MakeDesktopMenu(0, true);
break;
case e_icons:
m = MakeDesktopMenu(1, true);
break;
//.........这里部分代码省略.........
开发者ID:Jmos,项目名称:bbclean-xzero450,代码行数:101,代码来源:MenuMaker.cpp
示例7: while
/* ParseConfigurationFile - parse a configuration file */
BoardConfig *BoardConfig::parseConfigurationFile(const char *name)
{
char path[PATH_MAX];
BoardConfig *baseConfig, *config;
const char *src;
char *tag, *dst;
LineBuf buf;
FILE *fp;
int ch;
/* make a local copy of the name in lowercase */
src = name; dst = path;
while ((*dst++ = tolower(*src++)) != '\0')
;
/* check for a request for the default configuration */
if (strcmp(path, DEF_BOARD) == 0)
return getDefaultConfiguration();
/* make the configuration file name */
strcat(path, ".cfg");
/* open the configuration file */
if (!(fp = fopen(path, "r")))
return NULL;
/* create a new board configuration */
baseConfig = config = newBoardConfig(getDefaultConfiguration(), name);
/* initialize the line number */
buf.lineNumber = 0;
/* process each line in the configuration file */
while (fgets(buf.lineBuf, sizeof(buf.lineBuf), fp)) {
char *p;
int len;
/* check for a comment at the end of the line */
if ((p = strchr(buf.lineBuf, '#')) != NULL)
*p = '\0';
/* trim any trailing newline and spaces */
for (len = strlen(buf.lineBuf); len > 0; --len)
if (!isspace(buf.lineBuf[len-1]))
break;
buf.lineBuf[len] = '\0';
/* initialize token parser */
buf.linePtr = buf.lineBuf;
++buf.lineNumber;
/* look for the first token on the line */
switch (SkipSpaces(&buf)) {
case '\0': /* blank line */
case '#': /* comment */
// ignore blank lines and comments
break;
case '[': /* configuration tag */
/* get the configuration name */
++buf.linePtr;
if (!(tag = NextToken(&buf, "]", &ch)))
ParseError(&buf, "missing configuration tag");
if (ch != ']') {
if (SkipSpaces(&buf) != ']')
ParseError(&buf, "missing close bracket after configuration tag");
++buf.linePtr;
}
if (SkipSpaces(&buf) != '\0')
ParseError(&buf, "missing end of line");
/* add a new board configuration */
config = newBoardConfig(baseConfig, tag);
break;
default: /* tag:value pair */
/* get the tag */
if (!(tag = NextToken(&buf, ":", &ch)))
ParseError(&buf, "missing tag");
/* check for the colon separator */
if (ch != ':') {
if (SkipSpaces(&buf) != ':')
ParseError(&buf, "missing colon");
++buf.linePtr;
}
/* skip leading spaces before the value */
SkipSpaces(&buf);
/* set the configuration value */
config->setConfigField(tag, buf.linePtr);
break;
}
}
//.........这里部分代码省略.........
开发者ID:dbetz,项目名称:proploader-qt,代码行数:101,代码来源:config.cpp
示例8: Evaluate
double Evaluate (double acc, struct TokenStruct op, char *status, char *look, struct Variable *Vars) {
#ifdef DEBUG
printf ("Evaluate in; acc: %f, op: %s, status: %i, look: %c;\n", acc, op.Token, *status, *look);
#endif
/* if (*status > 0) { // if there are errors from other routines, handle error
return;
}*/
if (!op.priority) { // no operator present; return passed in value, if valid
if (!*status) { return acc; }
else if (*status < 0) { *status += 8; }
HandleError (op, *status, look);
return;
}
else if (op.priority == -1) { // invalid operator
*status = 1;
HandleError (op, *status, look);
return;
}
else if (op.priority == 1) {
if (op.Token[0] == ')' && *status < 0) {
*status = 0;
return acc;
}
else if (*status == -2 && op.Token[0] == ',') { return acc; } // end of argument
else { *status += 8; } // ',' after substatement (-1 -> 7) or other (0 -> 8)
HandleError (op, *status, look);
return;
}
struct TokenStruct val = NextToken (look);
double cur;
char neg = 0;
if (val.Token[0] == '-') { // if value is negative (has - preceding it), evaluate as negative and get next token
neg = 1;
val = NextToken (look);
}
if (val.Token[0] == '(') { cur = EvalSubStatement (status, look, Vars); } // sub statement
if (*status > 0) { return; } // invalid sub statement
struct TokenStruct nop = NextToken (look); // next operator
if (nop.Token[0] == '(') { // Function; TokenType (*Val) > 0 &&
cur = EvalFunction (val, status, look, Vars);
nop = NextToken (look); // get operator after function
}
else if (val.Token[0] != '(') { cur = Resolve (val, status, Vars); } // not a function or substatement, so resolve normally
if (*status > 0) { // invalid function or value
HandleError (val, *status, look);
return;
}
if (neg) { cur *= -1.0; } // account for negative numbers
switch (op.Token[0]) {
case '+':
if (nop.priority <= op.priority) { return Evaluate (acc + cur, nop, status, look, Vars); } // operator has equal or greater precedence than next operator
else { return acc + (Evaluate (cur, nop, status, look, Vars)); } // operator has less precedence than next operator
case '-':
if (nop.priority <= op.priority) { return Evaluate (acc - cur, nop, status, look, Vars); }
else { return acc - (Evaluate (cur, nop, status, look, Vars)); }
case '*':
if (nop.priority <= op.priority) { return Evaluate (acc * cur, nop, status, look, Vars); }
else { return acc * (Evaluate (cur, nop, status, look, Vars)); }
case '/':
if (nop.priority <= op.priority) { return Evaluate (acc / cur, nop, status, look, Vars); }
else { return acc / (Evaluate (cur, nop, status, look, Vars)); }
case '%':
if (nop.priority <= op.priority) { return Evaluate (fmod (acc, cur), nop, status, look, Vars); }
else { return fmod (acc, (Evaluate (cur, nop, status, look, Vars))); }
case '^':
if (nop.priority <= op.priority) { return Evaluate (pow (acc, cur), nop, status, look, Vars); }
else { return pow (acc, (Evaluate (cur, nop, status, look, Vars))); }
}
*status = 1;
HandleError (op, *status, look);
return; // invalid operator
}
开发者ID:TAParsons,项目名称:HomebrewCalculator,代码行数:85,代码来源:Calculator.c
示例9: Parse
char Parse (struct Variable *Vars) { // grabs first two tokens to see if they are an assign statment
// Symbol-specified functions:
// = (Assign), + (Add), - (Subtract), * (Multiply), / (Divide), % (Modulus), ^ (Power)
// Future symbols: ! (Factorial / Gamma function),
// Unused symbols: ~, `, @, #, $, &, [, ], {, }, |, \, ;, :, ', ", ?, ,, <, >,
line_index = 0;
char look = 0, status = 0;
printf ("> ");
fflush (0);
struct TokenStruct /*Oper*/and = NextToken (&look);
// check for calculator commands
if (!strcmp (and.Token, "DISPLAY")) { // display variable tree
char *disp = 0;
DisplayVars (Vars, disp, 0);
HandleError (and, 0, &look);
return 0;
}
else if (!strcmp (and.Token, "ECHO")) { // toggle input echo mode
ECHO = 1 - ECHO;
if (ECHO) { puts ("Input echo on"); } else { puts ("Input echo off"); }
HandleError (and, 0, &look);
return 0;
}
else if (!strcmp (and.Token, "HELP")) { // display help screen
puts ("Basic Calculator V 0.9");
puts ("--------------------------------------------------------------------------------");
puts ("This program is meant to be used as a general purpose calculator, akin to bc. Users can input arithmitic expressions of arbitrary length, assign and retrieve variables, and calculate common math functions. If the expression input isn't valid, the program displays an error message, indicates where in the line the problem occured, clears the input and resumes operation. In addition, users can work in interactive mode or redirect input scripts to execute a list of operations.");
puts ("--------------------------------------------------------------------------------");
puts ("COMMANDS: (case sensitive)");
puts (" DISPLAY : Display defined variables and their associated values.");
puts (" ECHO : Echo user input on next line. Useful when using an input script.");
puts (" HELP : Display this help screen.");
puts (" QUIT : Quit this calculator program.");
puts ("--------------------------------------------------------------------------------");
puts ("MATH FUNCTIONS: (not case sensitive)\n");
puts ("ABS / ABSOLUTE :\n return the absolute value of the argument. Accepts one argument.");
puts ("ASIN / ARCSINE :\n return the arc sine (inverse sine function) of the argument. Accepts one argument.");
puts ("ACOS / ARCCOSINE :\n return the arc cosine (inverse cosine function) of the argument. Accepts one argument.");
puts ("ATAN / ARCTANGENT :\n return the arc tangent (inverse tangent function) of the argument. Accepts one argument.");
puts ("COS / COSINE :\n return the cosine of the argument. Accepts one argument.");
puts ("DIST / DISTANCE / HYPOTENUSE :\n return the pythangorian distance (hypotenuse) between two values. Accepts two arguments.");
puts ("E :\n return the value of e. Accepts no arguments.");
puts ("EXP :\n return the exponent of the argument (e ^ arg). Accepts one argument.");
puts ("LN / NATURAL_LOG :\n return the natural log of the argument (arg = e ^ x). Accepts one argument.");
puts ("LOG / LOGARITHM :\n return the natural log of an argument OR the log of one argument in terms of another (log A / log b). Accepts one or two arguments.");
puts ("MOD / MODULUS :\n return the remainder of one argument divided by another. Accepts two arguments.");
puts ("PI :\n return the value of pi. Accepts no arguments.");
puts ("POW / POWER :\n return the value of one argument raised to the power of the other. Accepts two arguments.");
puts ("PROD / PRODUCT :\n return the product of the arguments. Accepts one or more arguments.");
puts ("SIN / SINE :\n return the sine of the argument. Accepts one argument.");
puts ("SQRT / SQUARE_ROOT :\n return the square root of the argument. Accepts one argument.");
puts ("SUM / SUMMATION :\n return the sum of the arguments. Accepts one or more arguments.");
puts ("TAN / TANGENT :\n return the tangent of the argument. Accepts one argument.");
HandleError (and, 0, &look);
return 0;
}
else if (!strcmp (and.Token, "QUIT")) { // quit calculator
HandleError (and, 0, &look);
return 1;
}
struct TokenStruct /*Oper*/ator;
struct TokenStruct tmp;
tmp.Token = malloc (sizeof (char) * 2);
tmp.Token = "+";
tmp.type = TokenType ('+');
tmp.priority = OpPriority ('+');
if (!and.priority) { return 0; } // no operand; blank line
double result = 0.0;
double sign = 1.0;
if (and.Token[0] == '-') { // negative value
sign = -1.0;
and = NextToken (&look);
}
if (and.Token[0] == '(') { result = sign * EvalSubStatement (&status, &look, Vars); } // substatement
if (status) { return 0; }
ator = NextToken (&look); // must be determined *after* substatement, and *before* function, assignment, or variable
// function, assignment, or variable; need operator to decide
if (ator.Token[0] == '(') { // function
result = sign * EvalFunction (and, &status, &look, Vars);
if (status) {
if (status == 5 || status == 9) { HandleError (and, status, &look); }
return 0;
}
ator = NextToken (&look);
result = Evaluate (result, ator, &status, &look, Vars);
}
else if (and.type == 1 && ator.Token[0] == '=') { result = Evaluate (0.0, tmp, &status, &look, Vars); } // assignment; don't need to check status here since it will be checked as soon as this statement is finished
else { // variable, number, substatement, or invalid
if (and.Token[0] != '(') {
//.........这里部分代码省略.........
开发者ID:TAParsons,项目名称:HomebrewCalculator,代码行数:101,代码来源:Calculator.c
示例10: ParseAttribute
void ParseAttribute (Declaration* D)
/* Parse an additional __attribute__ modifier */
{
/* Do we have an attribute? */
if (CurTok.Tok != TOK_ATTRIBUTE) {
/* No attribute, bail out */
return;
}
/* Skip the attribute token */
NextToken ();
/* Expect two(!) open braces */
ConsumeLParen ();
ConsumeLParen ();
/* Read a list of attributes */
while (1) {
ident AttrName;
const AttrDesc* Attr = 0;
/* Identifier follows */
if (CurTok.Tok != TOK_IDENT) {
/* No attribute name */
Error ("Attribute name expected");
/* Skip until end of attribute */
ErrorSkip ();
/* Bail out */
return;
}
/* Map the attribute name to its id, then skip the identifier */
strcpy (AttrName, CurTok.Ident);
Attr = FindAttribute (AttrName);
NextToken ();
/* Did we find a valid attribute? */
if (Attr) {
/* Call the handler */
Attr->Handler (D);
} else {
/* Attribute not known, maybe typo */
Error ("Illegal attribute: `%s'", AttrName);
/* Skip until end of attribute */
ErrorSkip ();
/* Bail out */
return;
}
/* If a comma follows, there's a next attribute. Otherwise this is the
** end of the attribute list.
*/
if (CurTok.Tok != TOK_COMMA) {
break;
}
NextToken ();
}
/* The declaration is terminated with two closing braces */
ConsumeRParen ();
ConsumeRParen ();
}
开发者ID:Aliandrana,项目名称:cc65,代码行数:70,代码来源:declattr.c
示例11: ParseFile
int
ParseFile(char* pcStart, FILE *fileDest, PFNOUTLINE OutputLine)
{
char *pc, *pcLine;
int nLine;
EXPORT exp;
int included;
//fprintf(stderr, "info: line %d, pcStart:'%.30s'\n", nLine, pcStart);
/* Loop all lines */
nLine = 1;
exp.nNumber = 0;
for (pcLine = pcStart; *pcLine; pcLine = NextLine(pcLine), nLine++)
{
pc = pcLine;
exp.nArgCount = 0;
exp.uFlags = 0;
exp.nNumber++;
//fprintf(stderr, "info: line %d, token:'%d, %.20s'\n",
// nLine, TokenLength(pcLine), pcLine);
/* Skip white spaces */
while (*pc == ' ' || *pc == '\t') pc++;
/* Skip empty lines, stop at EOF */
if (*pc == ';' || *pc <= '#') continue;
if (*pc == 0) return 0;
//fprintf(stderr, "info: line %d, token:'%.*s'\n",
// nLine, TokenLength(pc), pc);
/* Now we should get either an ordinal or @ */
if (*pc == '@') exp.nOrdinal = -1;
else exp.nOrdinal = atol(pc);
/* Go to next token (type) */
if (!(pc = NextToken(pc)))
{
fprintf(stderr, "error: line %d, unexpected end of line\n", nLine);
return -10;
}
//fprintf(stderr, "info: Token:'%.10s'\n", pc);
/* Now we should get the type */
if (CompareToken(pc, "stdcall"))
{
exp.nCallingConvention = CC_STDCALL;
}
else if (CompareToken(pc, "cdecl") ||
CompareToken(pc, "varargs"))
{
exp.nCallingConvention = CC_CDECL;
}
else if (CompareToken(pc, "fastcall"))
{
exp.nCallingConvention = CC_FASTCALL;
}
else if (CompareToken(pc, "thiscall"))
{
exp.nCallingConvention = CC_THISCALL;
}
else if (CompareToken(pc, "extern"))
{
exp.nCallingConvention = CC_EXTERN;
}
else if (CompareToken(pc, "stub"))
{
exp.nCallingConvention = CC_STUB;
}
else
{
fprintf(stderr, "error: line %d, expected type, got '%.*s' %d\n",
nLine, TokenLength(pc), pc, *pc);
return -11;
}
//fprintf(stderr, "info: nCallingConvention: %d\n", exp.nCallingConvention);
/* Go to next token (options or name) */
if (!(pc = NextToken(pc)))
{
fprintf(stderr, "fail2\n");
return -12;
}
/* Handle options */
included = 1;
while (*pc == '-')
{
if (CompareToken(pc, "-arch"))
{
/* Default to not included */
included = 0;
pc += 5;
/* Look if we are included */
//.........这里部分代码省略.........
开发者ID:mutoso-mirrors,项目名称:reactos,代码行数:101,代码来源:spec2def.c
示例12: doinit
void doinit(SYM *sp)
{
char lbl[200];
int algn;
enum e_sg oseg;
oseg = noseg;
lbl[0] = 0;
// Initialize constants into read-only data segment. Constants may be placed
// in ROM along with code.
if (sp->isConst) {
oseg = rodataseg;
}
if (sp->storage_class == sc_thread) {
if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
algn = imax(sp->tp->alignment,2);
else if (sp->tp->type==bt_pointer && sp->tp->val_flag)
algn = imax(sp->tp->GetBtp()->alignment,2);
else
algn = 2;
seg(oseg==noseg ? tlsseg : oseg,algn);
nl();
}
else if (sp->storage_class == sc_static || lastst==assign) {
if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
algn = imax(sp->tp->alignment,2);
else if (sp->tp->type==bt_pointer && sp->tp->val_flag)
algn = imax(sp->tp->GetBtp()->alignment,2);
else
algn = 2;
seg(oseg==noseg ? dataseg : oseg,algn); /* initialize into data segment */
nl(); /* start a new line in object */
}
else {
if (sp->tp->type==bt_struct || sp->tp->type==bt_union)
algn = imax(sp->tp->alignment,2);
else if (sp->tp->type==bt_pointer && sp->tp->val_flag)
algn = imax(sp->tp->GetBtp()->alignment,2);
else
algn = 2;
seg(oseg==noseg ? bssseg : oseg,algn); /* initialize into data segment */
nl(); /* start a new line in object */
}
if(sp->storage_class == sc_static || sp->storage_class == sc_thread) {
sp->realname = my_strdup(put_label(sp->value.i, (char *)sp->name->c_str(), GetNamespace(), 'D'));
}
else {
if (sp->storage_class == sc_global) {
strcpy_s(lbl, sizeof(lbl), "public ");
if (curseg==dataseg)
strcat_s(lbl, sizeof(lbl), "data ");
else if (curseg==bssseg)
strcat_s(lbl, sizeof(lbl), "bss ");
else if (curseg==tlsseg)
strcat_s(lbl, sizeof(lbl), "tls ");
}
strcat_s(lbl, sizeof(lbl), sp->name->c_str());
gen_strlab(lbl);
}
if (lastst == kw_firstcall) {
GenerateByte(1);
return;
}
else if( lastst != assign) {
genstorage(sp->tp->size);
}
else {
NextToken();
InitializeType(sp->tp);
}
endinit();
if (sp->storage_class == sc_global)
ofs.printf("\nendpublic\n");
}
开发者ID:BigEd,项目名称:Cores,代码行数:74,代码来源:Initializers.cpp
示例13: PragAux
void PragAux( void )
/******************/
{
struct {
unsigned f_call : 1;
unsigned f_loadds : 1;
unsigned f_rdosdev: 1;
unsigned f_export : 1;
unsigned f_parm : 1;
unsigned f_value : 1;
unsigned f_modify : 1;
unsigned f_frame : 1;
unsigned uses_auto: 1;
} have;
InitAuxInfo();
if( !GetAliasInfo() )
return;
if( CurToken != T_ID )
return;
SetCurrInfo( Buffer );
NextToken();
PragObjNameInfo( &AuxInfo.objname );
have.f_call = 0;
have.f_loadds = 0;
have.f_rdosdev = 0;
have.f_export = 0;
have.f_parm = 0;
have.f_value = 0;
have.f_modify = 0;
have.f_frame = 0;
have.uses_auto = 0; /* BBB - Jan 26, 1994 */
for( ;; ) {
if( !have.f_call && CurToken == T_EQUAL ) {
have.uses_auto = GetByteSeq( &AuxInfo.code );
have.f_call = 1;
} else if( !have.f_call && PragRecog( "far" ) ) {
AuxInfo.cclass |= FAR;
have.f_call = 1;
} else if( !have.f_call && PragRecog( "near" ) ) {
AuxInfo.cclass &= ~FAR;
AuxInfoFlg.f_near = 1;
have.f_call = 1;
} else if( !have.f_loadds && PragRecog( "loadds" ) ) {
AuxInfo.cclass |= LOAD_DS_ON_ENTRY;
have.f_loadds = 1;
} else if( !have.f_rdosdev && PragRecog( "rdosdev" ) ) {
AuxInfo.cclass |= LOAD_RDOSDEV_ON_ENTRY;
have.f_rdosdev = 1;
} else if( !have.f_export && PragRecog( "export" ) ) {
AuxInfo.cclass |= DLL_EXPORT;
have.f_export = 1;
} else if( !have.f_parm && PragRecog( "parm" ) ) {
GetParmInfo();
have.f_parm = 1;
} else if( !have.f_value && PragRecog( "value" ) ) {
GetRetInfo();
have.f_value = 1;
} else if( !have.f_value && PragRecog( "aborts" ) ) {
AuxInfo.cclass |= SUICIDAL;
have.f_value = 1;
} else if( !have.f_modify && PragRecog( "modify" ) ) {
GetSaveInfo();
have.f_modify = 1;
} else if( !have.f_frame && PragRecog( "frame" ) ) {
AuxInfo.cclass |= GENERATE_STACK_FRAME;
have.f_frame = 1;
} else {
break;
}
}
if( have.uses_auto ) {
/*
We want to force the calling routine to set up a [E]BP frame
for the use of this pragma. This is done by saying the pragma
modifies the [E]SP register. A kludge, but it works.
*/
HW_CTurnOn( AuxInfo.save, HW_SP );
}
CopyAuxInfo();
PragEnding();
}
开发者ID:XVilka,项目名称:owp4v1copy,代码行数:82,代码来源:cpragx86.c
示例14: GetByteSeq
local int GetByteSeq( byte_seq **code )
/*************************************/
{
unsigned char buff[MAXIMUM_BYTESEQ + 32];
char *name;
unsigned long offset;
fix_words fixword;
int uses_auto;
char too_many_bytes;
#if _CPU == 8086
bool use_fpu_emu = FALSE;
#endif
AsmSysInit( buff );
CompFlags.pre_processing = 1; /* enable macros */
NextToken();
too_many_bytes = 0;
uses_auto = 0;
offset = 0;
name = NULL;
for( ;; ) {
if( CurToken == T_STRING ) { /* 06-sep-91 */
#if _CPU == 8086
AsmLine( Buffer, GET_FPU_EMU( ProcRevision ) );
use_fpu_emu = FALSE;
#else
AsmLine( Buffer, FALSE );
#endif
NextToken();
if( CurToken == T_COMMA ) {
NextToken();
}
} else if( CurToken == T_CONSTANT ) {
#if _CPU == 8086
if( use_fpu_emu ) {
AddAFix( AsmCodeAddress, NULL, FIX_SEG, 0 );
use_fpu_emu = FALSE;
}
#endif
AsmCodeBuffer[AsmCodeAddress++] = Constant;
NextToken();
} else {
#if _CPU == 8086
use_fpu_emu = FALSE;
#endif
fixword = FixupKeyword();
if( fixword == FIXWORD_NONE )
break;
if( fixword == FIXWORD_FLOAT ) {
#if _CPU == 8086
if( GET_FPU_EMU( ProcRevision ) ) {
use_fpu_emu = TRUE;
}
#endif
} else { /* seg or offset */
if( CurToken != T_ID ) {
CErr1( ERR_EXPECTING_ID );
} else {
name = CStrSave( Buffer );
NextToken();
if( CurToken == T_PLUS ) {
NextToken();
if( CurToken == T_CONSTANT ) {
offset = Constant;
NextToken();
}
} else if( CurToken == T_MINUS ) {
NextToken();
if( CurToken == T_CONSTANT ) {
offset = -Constant;
NextToken();
}
}
}
switch( fixword ) {
case FIXWORD_RELOFF:
#if _CPU == 8086
AddAFix( AsmCodeAddress, name, FIX_RELOFF16, offset );
AsmCodeAddress += 2;
#else
AddAFix( AsmCodeAddress, name, FIX_RELOFF32, offset );
AsmCodeAddress += 4;
#endif
break;
case FIXWORD_OFFSET:
#if _CPU == 8086
AddAFix( AsmCodeAddress, name, FIX_OFF16, offset );
AsmCodeAddress += 2;
#else
AddAFix( AsmCodeAddress, name, FIX_OFF32, offset );
AsmCodeAddress += 4;
#endif
break;
case FIXWORD_SEGMENT:
AddAFix( AsmCodeAddress, name, FIX_SEG, 0 );
AsmCodeAddress += 2;
break;
}
}
}
//.........这里部分代码省略.........
开发者ID:XVilka,项目名称:owp4v1copy,代码行数:101,代码来源:cpragx86.c
示例15: ReadDetail
/*
**************************************************************************************
* ReadDetail:
* Read the position detail for all the position definitions in the position definition
* file. Store the values in the POSITIONS table.
*************************************************************************************
*/
void ReadDetail()
{
int p = 0;
char *nextName, *ptr;
int HPOffset, HPTable, HPCount;
int screenOffset, screenTable, screenCount;
int ScriptOffset, ScriptTable, ScriptCount;
int AFPOffset, AFPTable, AFPCount;
ALIAS *alias;
char *shareName;
infof("Reading position definition detail...");
while (NextLine())
{
if (strncmp(IOBuff,"DEFINE POSITION ",16))
{
if (!strncmp(IOBuff,"DEFINE ",7))
errorfp("Invalid DEFINE statement at line %d",CurrentLine);
continue;
}
ptr = IOBuff + 16;
nextName = NextToken(&ptr,STATIC_STRING);
if (nextName == NULL || strcmp(nextName,Positions[p].name.name)) continue;
HPCount = screenCount = ScriptCount = AFPCount = 0;
while (NextLine())
{
ptr = IOBuff;
if (!NextToken(&ptr,STATIC_STRING)) break;
if (sscanf(IOBuff,"HP OFFSET %d = %d",&HPTable,&HPOffset) == 2)
{
if (HPTable > TotalLanguages || HPTable < 1)
{
errorfp("Invalid HP table number %d at line %d",
HPTable,CurrentLine);
HPTable = 1;
}
Positions[p].HPOffset[HPTable-1] = HPOffset;
HPCount++;
}
else if (sscanf(IOBuff,"SCREEN OFFSET %d = %d",&screenTable,&screenOffset) == 2)
{
if (screenTable > TotalLanguages || screenTable < 1)
{
errorfp("Invalid screen table number %d at line %d",
screenTable,CurrentLine);
screenTable = 1;
}
Positions[p].screenOffset[screenTable-1] = screenOffset;
screenCount++;
}
else if (sscanf(IOBuff,"SCRIPT OFFSET %d = %d",&ScriptTable,&ScriptOffset) == 2)
{
if (ScriptTable > TotalLanguages || ScriptTable < 1)
{
errorfp("Invalid Script table number %d at line %d",
ScriptTable,CurrentLine);
ScriptTable = 1;
}
Positions[p].ScriptOffset[ScriptTable-1] = ScriptOffset;
ScriptCount++;
}
else if (sscanf(IOBuff,"AFP OFFSET %d = %d", &AFPTable, &a
|
请发表评论