Exemplo n.º 1
0
void GreaterLess(EVAL *Part1)
{
	EVAL Part2;

	shifts(Part1);

	GetOper();

	if (IsOper(">"))
	{
		SkipOper();

		GreaterLess(&Part2);
		
		Part1->Value = (Part1->Value > Part2.Value);
		return;
	}

	if (IsOper("<"))
	{
		SkipOper();

		GreaterLess(&Part2);
		
		Part1->Value = (Part1->Value < Part2.Value);
		return;
	}

	if (IsOper(">="))
	{
		SkipOper();

		GreaterLess(&Part2);
		
		Part1->Value = (Part1->Value >= Part2.Value);
		return;
	}

	if (IsOper("<="))
	{
		SkipOper();

		GreaterLess(&Part2);
		
		Part1->Value = (Part1->Value <= Part2.Value);
		return;
	}

}
Exemplo n.º 2
0
void assign(EVAL *Part1)		/* MAHandle assignments (=) */
{
//	EVAL Part2;

	logor(Part1);
	GetOper();

	if (IsOper("="))
	{
		SkipOper();
		
		Error(Error_Skip, "'=' is not implemented yet");
		ExitApp(1);
	}
}
Exemplo n.º 3
0
void Lexer(char* CharSource, Token* TokSource)
{
    char* CurChar = CharSource;
    Token* CurToken = TokSource;

    while (*CurChar != '\0')
    {
        GetNum(&CurChar, &CurToken);
        GetOper(&CurChar, &CurToken);
        GetPar(&CurChar, &CurToken);
        SkipChar(&CurChar);
    }
    CurToken->type = END;

    size_t i = 0;
    while ( TokSource[i].type != END )
    {
        switch (TokSource[i].type)
        {
        /* case OPER */
        case ADDITIVE_OPER:
            ;
        case MULTIPLICATIVE_OPER:
            ;
        case POWER_OPER:
            printf("%c", TokSource[i].value.oper);
            break;

        /* case PAR */
        case LPAR:
        case RPAR:
            printf("%c", TokSource[i].value.par);
            break;

        /* case NUM */
        case NUM:
            printf("[%f]", TokSource[i].value.number);
            break;
        case END:
            break;
        default:
            fprintf(stderr, "unexpected token %d\n", TokSource[i].type);
        }
        i++;
    }

    printf("\n");
}
Exemplo n.º 4
0
void shifts(EVAL *Part1)
{
	EVAL Part2;

	plus(Part1);

	GetOper();

	if (IsOper(">>"))
	{
		SkipOper();

		shifts(&Part2);
		
		Part1->Value >>= Part2.Value;
		return;
	}
Exemplo n.º 5
0
void or_ev(EVAL *Part1)				/* MAHandle addition and substraction */
{
	EVAL Part2;

	and_ev(Part1);

	GetOper();

	if (IsOper("|"))
	{
		SkipOper();
		or_ev(&Part2);
		
		Part1->Value |= Part2.Value;
		return;
	}
}
Exemplo n.º 6
0
void logand(EVAL *Part1)				/* MAHandle addition and substraction */
{
	EVAL Part2;

	xor_ev(Part1);

	GetOper();

	if (IsOper("&&"))
	{
		SkipOper();
		logand(&Part2);
		
		Part1->Value = (Part1->Value && Part2.Value);
		return;
	}
}
Exemplo n.º 7
0
void logor(EVAL *Part1)
{
	EVAL Part2;

	logand(Part1);

	GetOper();

	if (IsOper("||"))
	{
		SkipOper();

		logor(&Part2);

		Part1->Value = (Part1->Value || Part2.Value);
		return;

		return;
	}
}
Exemplo n.º 8
0
void and_ev(EVAL *Part1)				/* MAHandle addition and substraction */
{
	EVAL Part2;

	GreaterLess(Part1);

	GetOper();

	if (IsOper("&"))
	{
		SkipOper();
		and_ev(&Part2);
		
		Part1->Value &= Part2.Value;
		return;
	}
	
	if (IsOper("!="))
	{
		SkipOper();

		and_ev(&Part2);
		
		Part1->Value = ( Part1->Value != Part2.Value);
		return;
	}	
	
	if (IsOper("=="))
	{
		SkipOper();

		and_ev(&Part2);

		Part1->Value = (Part1->Value == Part2.Value);
		return;
	}
	
}