Ejemplo n.º 1
0
 @Override
 public void execute() throws ParserException {
   statement1.execute();
   setValue(statement1.getValue());
   if (statement2 != null) {
     statement2.execute();
     setValue(statement2.getValue());
   }
 }
 public Rule_Begin_Click_Statement(Rule_Context pContext, Reduction pToken) {
   super(pContext);
   // <Begin_Click_statement> ::= Begin-Click <Statements> End  | Begin-Click End | !Null
   if (pToken.size() > 2) {
     // NonterminalToken T = (NonterminalToken)pToken.Tokens[1];
     // this.Statements = new Rule_Statements(pContext, T);
     this.Statements = EnterRule.BuildStatements(pContext, (Reduction) pToken.get(1).getData());
   }
 }
  public Rule_UnHighlight(Rule_Context pContext, Reduction pToken) {
    super(pContext);
    // <IdentifierList> ::= <IdentifierList> Identifier | Identifier

    if (pToken.size() > 2) {
      // <Hide_Except_Statement> ::= HIDE '*' EXCEPT <IdentifierList>
      this.IsExceptList = true;
      this.IdentifierList = this.ExtractIdentifier(pToken.get(3)).toString().split(" ");
    } else {
      // <Hide_Some_Statement> ::= HIDE <IdentifierList>
      this.IdentifierList = this.ExtractIdentifier(pToken.get(1)).toString().split(" ");
    }
  }
Ejemplo n.º 4
0
 @Override
 public void execute() throws ParserException {
   // Write the data to the console
   ioDriver.write(dataToPrint.getValue().asObject().toString());
   if (variableName != null) {
     // Read console input from the user (assuming that EOLN is not echoed to console)
     StringBuilder sb = new StringBuilder(ioDriver.read());
     theParser.setProgramVariable(variableName, new Variable(sb.toString()));
   } else {
     ioDriver.write(EOLN);
   }
 }
Ejemplo n.º 5
0
 public Statements(GOLDParser parser) {
   Reduction reduction = parser.getCurrentReduction();
   if (reduction != null) {
     if (reduction.size() > 0 && reduction.size() < 3) {
       statement1 = reduction.get(0).asReduction();
       statement2 = (reduction.size() > 1) ? reduction.get(1).asReduction() : null;
     } else {
       parser.raiseParserException(
           Simple2.formatMessage(
               "error.param_count_range", "1", "2", String.valueOf(reduction.size())));
     }
   } else {
     parser.raiseParserException(Simple2.formatMessage("error.no_reduction"));
   }
 }
Ejemplo n.º 6
0
 public Print(GOLDParser parser) {
   theParser = parser;
   Reduction reduction = parser.getCurrentReduction();
   if (reduction != null) {
     if (reduction.size() == 2) {
       dataToPrint = reduction.get(1).asReduction();
       variableName = null;
     } else if (reduction.size() == 4) {
       dataToPrint = reduction.get(1).asReduction();
       variableName = reduction.get(3).asString();
     } else {
       if (reduction.size() < 3) {
         // print x form
         parser.raiseParserException(
             Simple3.formatMessage("error.param_count", "2", String.valueOf(reduction.size())));
       }
       // print x read y form
       parser.raiseParserException(
           Simple3.formatMessage("error.param_count", "4", String.valueOf(reduction.size())));
     }
   } else {
     parser.raiseParserException(Simple3.formatMessage("error.no_reduction"));
   }
 }