コード例 #1
0
 private boolean verifyEvent(String content, TextEvent event) {
   Parser parser = new Parser(fRules, fStartSymbol);
   StringBuffer tryContent = new StringBuffer(content);
   tryContent.replace(event.getBegin(), event.getEnd(), event.getText());
   fScanner.setStringToScann(tryContent.toString());
   if (parser.parser(fScanner)) {
     return true;
   } else {
     return false;
   }
 }
コード例 #2
0
    public boolean handleEvent(Text text, TextEvent event) {
      StringBuffer content = new StringBuffer(fView.getContent());
      content.replace(event.getBegin(), event.getEnd(), event.getText());
      Parser parser = new Parser(fRules, fStartSymbol);
      fScanner.setStringToScann(content.toString());
      parser.parser(fScanner);

      if (parser.finished()) {
        List<ASTNode> derivation = parser.getDerivation();
        fListener.valueChanges((SymbolASTNode) derivation.get(0));
      } else {
        fView.setText(content.toString());
        fView.update();
      }
      return true;
    }