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:
parent
45a378231b
commit
79c7619dab
|
@ -817,6 +817,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
struct ParseState PreState = *Parser;
|
||||||
enum LexToken Token = LexGetToken(Parser, &LexValue, TRUE);
|
enum LexToken Token = LexGetToken(Parser, &LexValue, TRUE);
|
||||||
if ((int)Token <= (int)TokenCloseBracket)
|
if ((int)Token <= (int)TokenCloseBracket)
|
||||||
{ /* it's an operator with precedence */
|
{ /* it's an operator with precedence */
|
||||||
|
@ -904,6 +905,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ /* it isn't a token from an expression */
|
{ /* it isn't a token from an expression */
|
||||||
|
*Parser = PreState;
|
||||||
Done = TRUE;
|
Done = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -916,7 +918,10 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
if (StackTop != NULL)
|
if (StackTop != NULL)
|
||||||
{
|
{
|
||||||
/* all that should be left is a single value on the stack */
|
/* 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;
|
return TRUE;
|
||||||
|
|
1
picoc.h
1
picoc.h
|
@ -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 Parse(const char *FileName, const char *Source, int SourceLen, int RunIt);
|
||||||
void ParseInteractive();
|
void ParseInteractive();
|
||||||
void ParseCleanup();
|
void ParseCleanup();
|
||||||
|
void ParserCopyPos(struct ParseState *To, struct ParseState *From);
|
||||||
|
|
||||||
/* expression.c */
|
/* expression.c */
|
||||||
int ExpressionParse(struct ParseState *Parser, struct Value **Result);
|
int ExpressionParse(struct ParseState *Parser, struct Value **Result);
|
||||||
|
|
Loading…
Reference in a new issue