A little more...

I probably should just say what i am doing to clear things up.

this'll be log, so please be patient

See,im writing an interpreter. Okay...Not really, but it only interprets expressions. like you would give it

2+2

and it would yield

4

if your thinking python, thats where i got the idea;)

now one of the things i wanted to do with it is to make it more like real arithmetic syntax, by the use of coefficents. For those who dont know what this is, well i cant express it in words but i can show it

2y
^--the 2 is a coefficient of y, which evauluated would be 2*y.

as well as the algebraic syntax of what would be multipication
like:
ab=a*b; adb=a*d*b; 3(3+2)=3*(3+2);

well, there was one problem. see, i included the feature of variable being put together, and in the program, it would multiply them,

but that puts forth a problem in parsing. i cant know when a variable name ends or when it begins.

see this

hello

could be h*ello or he*llo etc.

Then i thought of using capitals for the beginning of variables, like this:

He and Llo.
so

HeLlo

would become

He*Llo

but it seems so tedious to the user, so it though i could just use one letter variables, but that limits it to 52 variables only. There is another option, to look at every character in a thought of idetifier. and every new character as we go along and compare it with the already stored variables, but thats to much processing.

Tell me which to do. or give any other sugestions. thats all. thank you.

Comments

  • :
    : but that puts forth a problem in parsing. i cant know when a variable name ends or when it begins.
    :

    That's why God invented the asterisk to represent multiplication -- ab*bc -- this prevents that sort of amiguity. From that we immediately know that ab and bc are both variable names.
  • : I probably should just say what i am doing to clear things up.
    :
    : this'll be log, so please be patient
    :
    : See,im writing an interpreter. Okay...Not really, but it only interprets expressions. like you would give it
    :
    : 2+2
    :
    : and it would yield
    :
    : 4
    :
    : if your thinking python, thats where i got the idea;)
    :
    : now one of the things i wanted to do with it is to make it more like real arithmetic syntax, by the use of coefficents. For those who dont know what this is, well i cant express it in words but i can show it
    :
    : 2y
    : ^--the 2 is a coefficient of y, which evauluated would be 2*y.
    :
    : as well as the algebraic syntax of what would be multipication
    : like:
    : ab=a*b; adb=a*d*b; 3(3+2)=3*(3+2);
    :
    : well, there was one problem. see, i included the feature of variable being put together, and in the program, it would multiply them,
    :
    : but that puts forth a problem in parsing. i cant know when a variable name ends or when it begins.
    :
    : see this
    :
    : hello
    :
    : could be h*ello or he*llo etc.
    :
    : Then i thought of using capitals for the beginning of variables, like this:
    :
    : He and Llo.
    : so
    :
    : HeLlo
    :
    : would become
    :
    : He*Llo
    :
    : but it seems so tedious to the user, so it though i could just use one letter variables, but that limits it to 52 variables only. There is another option, to look at every character in a thought of idetifier. and every new character as we go along and compare it with the already stored variables, but thats to much processing.
    :
    : Tell me which to do. or give any other sugestions. thats all. thank you.
    :

    I would either require all multi character variables to be all caps, or be enclosed in paranthesis:

    2abTEMP would evaluate to 2*a*b*TEMP or
    2ab(temp) would evaluate to 2*a*b*temp

    It would be hard to evaluate variables even if they are predefine because of cases like this:

    int temp;
    int temp2;

    the expression: "3abtemp2" could not be parsed reliably.




Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories