Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void parseStmt(String token) throws IOException
- {
- int val;
- String text;
- if (token.equals("load")) // ::= load <string>
- {
- token = getToken();
- text = parseString(token);
- line = loadFile(text) + line;
- }
- else if (token.equals("print")) // ::= print <string> | print <expr>
- {
- token = getToken();
- if (token.charAt(0) == '"')
- {
- text = parseString (token);
- // execute part
- if (eval == true)
- System.out.println(text);
- }
- else
- {
- val = parseExpr(token);
- // execute part
- if (eval == true)
- System.out.println(val);
- }
- }
- else if (token.equals("input")) // ::= input <var>
- {
- token = getToken();
- val = parseVar(token);
- // execute part
- if (eval == true)
- {
- System.out.print("? ");
- val = scan.nextInt();
- storeVar(token, val);
- }
- }
- else if (token.equals("if"))
- {
- token = getToken();
- // determines whether the condition was true or not
- boolean cond = parseCond(token);
- // assigns the boolean value (true or false) to the global eval boolean
- eval = cond;
- token = getToken();
- parseStmt(token);
- }
- else if (isVar(token))
- {
- }
- else
- {
- reportError(token);
- }
- eval = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement