I have an assignment for my computer organization class and I'm a little stuck. My professor wants us to create a java program that translates a made-up language: Tiny into a java program that runs correctly.
here is the spec for The Tiny Programming Language:
There is only one data type: integer.
A legal identifier may have one and only one lowercase letter in it (thus there are only 26 possible different identifiers).
A literal integer may have one and only one digit in it. Thus, the only literals are 0 to 9; no larger integers and no negative integers.
There are no declaration statements. All possible identifiers are implicitly delared to be integers and are initialized to 0.
All addition is done modulo 1000.
Statements must begin in column one and may contain no blank or tab characters.
There are three (and only three) kinds of statements in Tiny (in this description, the symbol A represents any legal identifier and the symbols X and Y represent any legal identifier or literal):
There are three statements types in Tiny.
Assigns the value of X to variable A. Remember, A can be any variable and X can be any variable OR single-digit number.
Assigns the sum of X and Y to variable A. Remember, A can be any identifier. X and Y can be any identifier OR single-digit number. Thus, although the largest constant is 9, variables can take on values larger than 9.
Outputs the value of X followed by a newline character. Remember, X can be any variable OR single-digit number.
MY program works almost completely, the problem i have run into is that for my input data:
the variable z is never declared, in Tiny there are no declarations everything is declared implicitly and is initialized to 0. So instead of printing 0 my translated program gives me an error because I havent declared z.
Here is my code:
And here is the translated code i get with these inputs:
Any help would be great.
"If the facts don't fit the theory, get new facts" --Albert Einstein