Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void atom_expression() throws IOException
- {
- switch(this.curentSymbolStr)
- {
- case "LPARENT":
- nextSymbol();
- this.dump("Atom_expression -> ( Expressions )");
- expressions();
- if(this.curentSymbolStr.equals("RPARENT"))
- {
- nextSymbol();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing ')'");
- break;
- case "LBRACE":
- nextSymbol();
- this.dump("Atom_expression -> { atom_expression''");
- atom_expression__();
- break;
- case "LOG_CONST":
- nextSymbol();
- this.dump("Atom_expression -> log_const");
- break;
- case "INT_CONST":
- nextSymbol();
- this.dump("Atom_expression -> int_const");
- break;
- case "STR_CONST":
- nextSymbol();
- this.dump("Atom_expression -> str_const");
- break;
- case "IDENTIFIER":
- nextSymbol();
- this.dump("Atom_expression -> identifier Atom_expression'");
- atom_expression_();
- break;
- default:
- Report.error(curentSymbol.position, "ERROR: expected parameters: '(', '{', 'log_const', 'int_const', 'str_const' or 'identifier'");
- break;
- }
- }
- private void atom_expression_() throws IOException
- {
- switch(this.curentSymbolStr)
- {
- case "SEMIC":
- case "COLON":
- case "LBRACKET":
- case "RBRACKET":
- case "RPARENT":
- case "ASSIGN":
- case "COMMA":
- case "LBRACE":
- case "RBRACE":
- case "IOR":
- case "AND":
- case "EQU":
- case "NEQ":
- case "LEQ":
- case "GEQ":
- case "LTH":
- case "GTH":
- case "ADD":
- case "SUB":
- case "MUL":
- case "DIV":
- case "MOD":
- case "THEN":
- case "ELSE":
- case "EOF":
- this.dump("Atom_expression' -> $");
- break;
- case "LPARENT":
- nextSymbol();
- this.dump("Atom_expression' -> ( Expressions )");
- expressions();
- if(this.curentSymbolStr.equals("RPARENT"))
- {
- nextSymbol();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing ')'");
- break;
- default:
- Report.error(curentSymbol.position, "ERROR: expected parameters: ';', ':', '[', ']', '(', ')', '=', ',', '{', '}', '|', '&', '==', '!=', '<=', '>=', '<', '>', '*', '/', '%', 'then', 'else' or 'eof'");
- break;
- }
- }
- private void atom_expression__() throws IOException
- {
- switch(this.curentSymbolStr)
- {
- case "LPARENT":
- case "LBRACE":
- case "ADD":
- case "SUB":
- case "NOT":
- case "LOG_CONST":
- case "INT_CONST":
- case "STR_CONST":
- case "IDENTIFIER":
- this.dump("Atom_expression'' -> Expression = Expression }");
- expression();
- if(this.curentSymbolStr.equals("ASSIGN"))
- {
- nextSymbol();
- expression();
- if(this.curentSymbolStr.equals("RBRACE"))
- {
- nextSymbol();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing '}'");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing '='");
- break;
- case "IF":
- nextSymbol();
- this.dump("Atom_expression'' -> if Expression then Expression Atom_expression'''");
- expression();
- if(this.curentSymbolStr.equals("THEN"))
- {
- nextSymbol();
- expression();
- atom_expression___();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing 'then'");
- break;
- case "WHILE":
- nextSymbol();
- this.dump("Atom_expression'' -> while Expression : Expression }");
- expression();
- if(this.curentSymbolStr.equals("COLON"))
- {
- nextSymbol();
- expression();
- if(this.curentSymbolStr.equals("RBRACE"))
- {
- nextSymbol();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing '}'");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing ':'");
- break;
- case "FOR":
- nextSymbol();
- this.dump("Atom_expression'' -> for identifier = Expression , Expression , Expression : Expression }");
- //expression();
- if(this.curentSymbolStr.equals("IDENTIFIER"))
- {
- nextSymbol();
- if(this.curentSymbolStr.equals("ASSIGN"))
- {
- nextSymbol();
- expression();
- if(this.curentSymbolStr.equals("COMMA"))
- {
- nextSymbol();
- expression();
- if(this.curentSymbolStr.equals("COMMA"))
- {
- nextSymbol();
- expression();
- if(this.curentSymbolStr.equals("COLON"))
- {
- nextSymbol();
- expression();
- if(this.curentSymbolStr.equals("RBRACE"))
- {
- nextSymbol();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing '}'");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing ':'");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing ','");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing ','");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing '='");
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing 'identifier'");
- break;
- default:
- Report.error(curentSymbol.position, "ERROR: expected parameters: 'if', 'while' or 'for'");
- break;
- }
- }
- private void atom_expression___() throws IOException
- {
- switch(this.curentSymbolStr)
- {
- case "RBRACE":
- nextSymbol();
- this.dump("Atom_expression''' -> }");
- break;
- case "ELSE":
- nextSymbol();
- this.dump("Atom_expression''' -> else Expression }");
- expression();
- if(this.curentSymbolStr.equals("RBRACE"))
- {
- nextSymbol();
- }
- else
- Report.error(curentSymbol.position, "ERROR: missing '}'");
- break;
- default:
- Report.error(curentSymbol.position, "ERROR: expected parameters: '}' or 'else'");
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement