Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.98 KB | None | 0 0
  1. private void atom_expression() throws IOException
  2.     {
  3.         switch(this.curentSymbolStr)
  4.         {
  5.             case "LPARENT":
  6.                 nextSymbol();
  7.                 this.dump("Atom_expression -> ( Expressions )");
  8.                 expressions();
  9.                
  10.                 if(this.curentSymbolStr.equals("RPARENT"))
  11.                 {
  12.                     nextSymbol();
  13.                 }
  14.                 else
  15.                     Report.error(curentSymbol.position, "ERROR: missing ')'");
  16.                
  17.                 break;
  18.                
  19.             case "LBRACE":
  20.                 nextSymbol();
  21.                 this.dump("Atom_expression -> { atom_expression''");
  22.                 atom_expression__();
  23.                 break;
  24.                
  25.             case "LOG_CONST":
  26.                 nextSymbol();
  27.                 this.dump("Atom_expression -> log_const");
  28.                 break;
  29.                
  30.             case "INT_CONST":
  31.                 nextSymbol();
  32.                 this.dump("Atom_expression -> int_const");
  33.                 break;
  34.                
  35.             case "STR_CONST":
  36.                 nextSymbol();
  37.                 this.dump("Atom_expression -> str_const");
  38.                 break;
  39.                
  40.             case "IDENTIFIER":
  41.                 nextSymbol();
  42.                 this.dump("Atom_expression -> identifier Atom_expression'");
  43.                 atom_expression_();
  44.                 break;
  45.                
  46.             default:
  47.                 Report.error(curentSymbol.position, "ERROR: expected parameters: '(', '{', 'log_const', 'int_const', 'str_const' or 'identifier'");
  48.                 break;
  49.         }
  50.     }
  51.    
  52.     private void atom_expression_() throws IOException
  53.     {
  54.         switch(this.curentSymbolStr)
  55.         {
  56.             case "SEMIC":
  57.             case "COLON":
  58.             case "LBRACKET":
  59.             case "RBRACKET":
  60.             case "RPARENT":
  61.             case "ASSIGN":
  62.             case "COMMA":
  63.             case "LBRACE":
  64.             case "RBRACE":
  65.             case "IOR":
  66.             case "AND":
  67.             case "EQU":
  68.             case "NEQ":
  69.             case "LEQ":
  70.             case "GEQ":
  71.             case "LTH":
  72.             case "GTH":
  73.             case "ADD":
  74.             case "SUB":
  75.             case "MUL":
  76.             case "DIV":
  77.             case "MOD":
  78.             case "THEN":
  79.             case "ELSE":
  80.             case "EOF":
  81.                 this.dump("Atom_expression' -> $");
  82.                 break;
  83.                    
  84.             case "LPARENT":
  85.                 nextSymbol();
  86.                 this.dump("Atom_expression' -> ( Expressions )");
  87.                 expressions();
  88.                
  89.                 if(this.curentSymbolStr.equals("RPARENT"))
  90.                 {
  91.                     nextSymbol();
  92.                 }
  93.                 else
  94.                     Report.error(curentSymbol.position, "ERROR: missing ')'");
  95.                
  96.                 break;
  97.                
  98.             default:
  99.                 Report.error(curentSymbol.position, "ERROR: expected parameters: ';', ':', '[', ']', '(', ')', '=', ',', '{', '}', '|', '&', '==', '!=', '<=', '>=', '<', '>', '*', '/', '%', 'then', 'else' or 'eof'");
  100.                 break;
  101.         }
  102.     }
  103.    
  104.     private void atom_expression__() throws IOException
  105.     {
  106.         switch(this.curentSymbolStr)
  107.         {
  108.             case "LPARENT":
  109.             case "LBRACE":
  110.             case "ADD":
  111.             case "SUB":
  112.             case "NOT":
  113.             case "LOG_CONST":
  114.             case "INT_CONST":
  115.             case "STR_CONST":
  116.             case "IDENTIFIER":
  117.                 this.dump("Atom_expression'' -> Expression = Expression }");
  118.                 expression();
  119.                
  120.                 if(this.curentSymbolStr.equals("ASSIGN"))
  121.                 {
  122.                     nextSymbol();
  123.                     expression();
  124.                    
  125.                     if(this.curentSymbolStr.equals("RBRACE"))
  126.                     {
  127.                         nextSymbol();
  128.                     }
  129.                     else
  130.                         Report.error(curentSymbol.position, "ERROR: missing '}'");
  131.                 }
  132.                 else
  133.                     Report.error(curentSymbol.position, "ERROR: missing '='");
  134.                
  135.                 break;
  136.            
  137.             case "IF":
  138.                 nextSymbol();
  139.                 this.dump("Atom_expression'' -> if Expression then Expression Atom_expression'''");
  140.                 expression();
  141.                
  142.                 if(this.curentSymbolStr.equals("THEN"))
  143.                 {
  144.                     nextSymbol();
  145.                    
  146.                     expression();
  147.                     atom_expression___();
  148.                 }
  149.                 else
  150.                     Report.error(curentSymbol.position, "ERROR: missing 'then'");
  151.                
  152.                 break;
  153.                
  154.             case "WHILE":
  155.                 nextSymbol();
  156.                 this.dump("Atom_expression'' -> while Expression : Expression }");
  157.                 expression();
  158.                
  159.                 if(this.curentSymbolStr.equals("COLON"))
  160.                 {
  161.                     nextSymbol();
  162.                     expression();
  163.                    
  164.                     if(this.curentSymbolStr.equals("RBRACE"))
  165.                     {
  166.                         nextSymbol();
  167.                     }
  168.                     else
  169.                         Report.error(curentSymbol.position, "ERROR: missing '}'");
  170.                 }
  171.                 else
  172.                     Report.error(curentSymbol.position, "ERROR: missing ':'");
  173.                
  174.                 break;
  175.                
  176.             case "FOR":
  177.                 nextSymbol();
  178.                 this.dump("Atom_expression'' -> for identifier = Expression , Expression , Expression : Expression }");
  179.                 //expression();
  180.                 if(this.curentSymbolStr.equals("IDENTIFIER"))
  181.                 {
  182.                     nextSymbol();
  183.                     if(this.curentSymbolStr.equals("ASSIGN"))
  184.                     {
  185.                         nextSymbol();
  186.                         expression();
  187.  
  188.                         if(this.curentSymbolStr.equals("COMMA"))
  189.                         {
  190.                             nextSymbol();
  191.                             expression();
  192.  
  193.                             if(this.curentSymbolStr.equals("COMMA"))
  194.                             {
  195.                                 nextSymbol();
  196.                                 expression();
  197.  
  198.                                 if(this.curentSymbolStr.equals("COLON"))
  199.                                 {
  200.                                     nextSymbol();
  201.                                     expression();
  202.                                    
  203.                                     if(this.curentSymbolStr.equals("RBRACE"))
  204.                                     {
  205.                                         nextSymbol();
  206.                                     }
  207.                                     else
  208.                                         Report.error(curentSymbol.position, "ERROR: missing '}'");
  209.                                 }
  210.                                 else
  211.                                     Report.error(curentSymbol.position, "ERROR: missing ':'");
  212.                             }
  213.                             else
  214.                                 Report.error(curentSymbol.position, "ERROR: missing ','");
  215.                         }
  216.                         else
  217.                             Report.error(curentSymbol.position, "ERROR: missing ','");
  218.                     }
  219.                     else
  220.                         Report.error(curentSymbol.position, "ERROR: missing '='");
  221.                 }
  222.                 else
  223.                     Report.error(curentSymbol.position, "ERROR: missing 'identifier'");
  224.                
  225.                 break;
  226.                
  227.             default:
  228.                 Report.error(curentSymbol.position, "ERROR: expected parameters: 'if', 'while' or 'for'");
  229.                 break;
  230.         }
  231.     }
  232.    
  233.      private void atom_expression___() throws IOException
  234.     {
  235.         switch(this.curentSymbolStr)
  236.         {
  237.             case "RBRACE":
  238.                 nextSymbol();
  239.                 this.dump("Atom_expression''' -> }");
  240.                 break;
  241.                
  242.             case "ELSE":
  243.                 nextSymbol();
  244.                 this.dump("Atom_expression''' -> else Expression }");
  245.                 expression();
  246.                
  247.                 if(this.curentSymbolStr.equals("RBRACE"))
  248.                 {
  249.                     nextSymbol();
  250.                 }
  251.                 else
  252.                     Report.error(curentSymbol.position, "ERROR: missing '}'");
  253.                  
  254.                 break;
  255.                
  256.             default:
  257.                 Report.error(curentSymbol.position, "ERROR: expected parameters: '}' or 'else'");
  258.                 break;
  259.         }
  260.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement