Hi.
I'm writing a program that evaluates expressions, kind of what scanners and parsers do on compilers. Now I got this trouble:
I need to check for assignation and comparisson expressions, that is, I need to look in the text for symbols like: =, <, >, >=, <=, ==, etc.
The problem comes when I find those symbols right beside a token, for example:
var= a;
or var =a;
instead of var = a; (see the space between the characters)
And same with the other operators:
a>b
instead of a > b
When that happens, the token I get is "var=" or "a>", which is not what I need. I need to get "var" "=" "a", wherever the operator is written(right, center or left). Any idea of how can i do that?
BTW: I'm saving each token I get from the file in a singly linked list.
THANKS.
I'm writing a program that evaluates expressions, kind of what scanners and parsers do on compilers. Now I got this trouble:
I need to check for assignation and comparisson expressions, that is, I need to look in the text for symbols like: =, <, >, >=, <=, ==, etc.
The problem comes when I find those symbols right beside a token, for example:
var= a;
or var =a;
instead of var = a; (see the space between the characters)
And same with the other operators:
a>b
instead of a > b
When that happens, the token I get is "var=" or "a>", which is not what I need. I need to get "var" "=" "a", wherever the operator is written(right, center or left). Any idea of how can i do that?
BTW: I'm saving each token I get from the file in a singly linked list.
THANKS.