Пример #1
0
 public void S() throws IOException {
   AbstractNode node;
   AbstractNode exprn;
   Id assId;
   if (look.tag == '(' || look.tag == Tag.NUM) {
     node = E();
   } else if (look.tag == Tag.ID) {
     currentAssigneeSymbol = (Id) look;
     match(Tag.ID);
     if (look.tag == '=') {
       match('=');
       exprn = E();
       node =
           threeAddressCodeGenerator.generateCodeForNode(
               threeAddressCodeGenerator.insertAndGetLeaf(currentAssigneeSymbol),
               exprn,
               "="); //// generate code for assignment
     } else {
       skipId = currentAssigneeSymbol;
       currentAssigneeSymbol = null;
       skipFlag = 1;
       node = E();
     }
   } else {
     throw new Error("Syntax Error");
   }
 }
Пример #2
0
 public AbstractNode T1(AbstractNode factnodeinh) throws IOException {
   AbstractNode node; // node which rerpesents the operation so far
   AbstractNode snode; // synthesised attribute which gives the full answer
   AbstractNode prefn = factnodeinh; // previous factor nonterminal is inherited
   AbstractNode curfn;
   if (look.tag == '*') {
     match('*');
     curfn = F();
     // System.out.print("*");
     postFix.append("*");
     stackMachine.evaluate("*");
     node =
         threeAddressCodeGenerator.generateCodeForNode(
             prefn, curfn, "*"); // generate code for node
     snode = T1(node);
   } else {
     snode = factnodeinh;
   }
   return snode;
 }