Case expression handling fixed.
git-svn-id: http://picoc.googlecode.com/svn/trunk@232 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
parent
ca628b8cb3
commit
9fdee50576
11
expression.c
11
expression.c
|
@ -1083,13 +1083,14 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
int LocalPrecedence;
|
int LocalPrecedence;
|
||||||
int Precedence = 0;
|
int Precedence = 0;
|
||||||
struct ExpressionStack *StackTop = NULL;
|
struct ExpressionStack *StackTop = NULL;
|
||||||
debugf("ExpressionParse():\n");
|
int TernaryDepth = 0;
|
||||||
|
|
||||||
|
debugf("ExpressionParse():\n");
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
struct ParseState PreState = *Parser;
|
struct ParseState PreState = *Parser;
|
||||||
enum LexToken Token = LexGetToken(Parser, &LexValue, TRUE);
|
enum LexToken Token = LexGetToken(Parser, &LexValue, TRUE);
|
||||||
if ((int)Token > TokenComma && (int)Token <= (int)TokenCloseBracket)
|
if ((int)Token > TokenComma && (int)Token <= (int)TokenCloseBracket && (Token != TokenColon || TernaryDepth != 0))
|
||||||
{
|
{
|
||||||
/* it's an operator with precedence */
|
/* it's an operator with precedence */
|
||||||
if (PrefixState)
|
if (PrefixState)
|
||||||
|
@ -1206,7 +1207,7 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
PrefixState = FALSE;
|
PrefixState = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((int)Token > TokenComma && (int)Token <= (int)TokenCharacterConstant)
|
else if ((int)Token > TokenCloseBracket && (int)Token <= TokenCharacterConstant)
|
||||||
{
|
{
|
||||||
/* it's a value of some sort, push it */
|
/* it's a value of some sort, push it */
|
||||||
if (!PrefixState)
|
if (!PrefixState)
|
||||||
|
@ -1224,6 +1225,10 @@ int ExpressionParse(struct ParseState *Parser, struct Value **Result)
|
||||||
|
|
||||||
} while (!Done);
|
} while (!Done);
|
||||||
|
|
||||||
|
/* check that brackets have been closed */
|
||||||
|
if (BracketPrecedence > 0)
|
||||||
|
ProgramFail(Parser, "brackets not closed");
|
||||||
|
|
||||||
/* scan and collapse the stack to precedence 0 */
|
/* scan and collapse the stack to precedence 0 */
|
||||||
ExpressionStackCollapse(Parser, &StackTop, 0);
|
ExpressionStackCollapse(Parser, &StackTop, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue