New expression system now handles simple numeric values

git-svn-id: http://picoc.googlecode.com/svn/trunk@214 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2009-03-30 11:16:40 +00:00
parent 45a378231b
commit 79c7619dab
2 changed files with 7 additions and 1 deletions

View file

@ -817,6 +817,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
do
{
struct ParseState PreState = *Parser;
enum LexToken Token = LexGetToken(Parser, &LexValue, TRUE);
if ((int)Token <= (int)TokenCloseBracket)
{ /* it's an operator with precedence */
@ -904,6 +905,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
}
else
{ /* it isn't a token from an expression */
*Parser = PreState;
Done = TRUE;
}
@ -916,7 +918,10 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
if (StackTop != NULL)
{
/* all that should be left is a single value on the stack */
HeapPopStack((void *)StackTop - sizeof(struct ExpressionStack), sizeof(struct ExpressionStack));
if (Parser->Mode == RunModeRun)
*Result = StackTop->Val;
HeapPopStack(StackTop, sizeof(struct ExpressionStack));
}
return TRUE;

View file

@ -271,6 +271,7 @@ struct Value *ParseFunctionDefinition(struct ParseState *Parser, struct ValueTyp
void Parse(const char *FileName, const char *Source, int SourceLen, int RunIt);
void ParseInteractive();
void ParseCleanup();
void ParserCopyPos(struct ParseState *To, struct ParseState *From);
/* expression.c */
int ExpressionParse(struct ParseState *Parser, struct Value **Result);