示例#1
0
 /**
  * Returns a canonical mapping for the specified nonterminal label; if <code>label</code> already
  * is in canonical form, it is returned. The canonical mapping refers to transformations performed
  * on nonterminals during the training process. Before obtaining a label's canonical form, it is
  * also stripped of all Treebank augmentations, meaning that only the characters before the first
  * occurrence of '-', '=' or '|' are kept.
  *
  * @return a <code>Symbol</code> with the same print name as <code>label</code>, except that all
  *     training transformations and Treebank augmentations have been undone and stripped
  */
 public final Symbol getCanonical(Symbol label) {
   if (outputLexLabels) {
     char lbracket = nonTreebankLeftBracket();
     char rbracket = nonTreebankRightBracket();
     int lbracketIdx = label.toString().indexOf(lbracket);
     int rbracketIdx = label.toString().indexOf(rbracket);
     if (lbracketIdx != -1 && rbracketIdx != -1) {
       String labelStr = label.toString();
       Symbol unlexLabel =
           Symbol.get(labelStr.substring(0, lbracketIdx) + labelStr.substring(rbracketIdx + 1));
       String canonStr = defaultGetCanonical(unlexLabel).toString();
       return Symbol.get(canonStr + labelStr.substring(lbracketIdx, rbracketIdx + 1));
     }
   }
   return defaultGetCanonical(label);
 }
示例#2
0
  public StructureObject(Symbol symbol) {

    structureClass = (StructureClass) LispClass.findClass(symbol /*, true*/); // Might return null.
    if (structureClass == null) {
      System.err.println("No mitens sitten: " + BuiltInClass.SYSTEM_STREAM.toString());
      System.err.println("joopa joo:" + Symbol.SYSTEM_STREAM.name);
      System.err.println(
          "Oh noes, structure object got a null class:"
              + symbol.toString()
              + ", symbol name:"
              + symbol.name);
    }
    slots = new LispObject[0];
  }
示例#3
0
  public void receiveSaslInit(final SaslInit saslInit) {
    Symbol mechanism = saslInit.getMechanism();
    final Binary initialResponse = saslInit.getInitialResponse();
    byte[] response = initialResponse == null ? new byte[0] : initialResponse.getArray();

    try {
      _saslServer = _saslServerProvider.getSaslServer(mechanism.toString(), "localhost");

      // Process response from the client
      byte[] challenge = _saslServer.evaluateResponse(response != null ? response : new byte[0]);

      if (_saslServer.isComplete()) {
        SaslOutcome outcome = new SaslOutcome();

        outcome.setCode(SaslCode.OK);
        _saslFrameOutput.send(new SASLFrame(outcome), null);
        synchronized (getLock()) {
          _saslComplete = true;
          _authenticated = true;
          getLock().notifyAll();
        }

        if (_onSaslCompleteTask != null) {
          _onSaslCompleteTask.run();
        }

      } else {
        SaslChallenge challengeBody = new SaslChallenge();
        challengeBody.setChallenge(new Binary(challenge));
        _saslFrameOutput.send(new SASLFrame(challengeBody), null);
      }
    } catch (SaslException e) {
      SaslOutcome outcome = new SaslOutcome();

      outcome.setCode(SaslCode.AUTH);
      _saslFrameOutput.send(new SASLFrame(outcome), null);
      synchronized (getLock()) {
        _saslComplete = true;
        _authenticated = false;
        getLock().notifyAll();
      }
      if (_onSaslCompleteTask != null) {
        _onSaslCompleteTask.run();
      }
    }
  }
示例#4
0
 @Override
 protected String visitSymbol(Symbol symbol, Void context) {
   return symbol.toString();
 }
示例#5
0
 public Builder(Expression expression, Symbol body) {
   super(String.format("while (%s) %s", expression.toString(), body.toString()));
   this.expression = expression;
   this.body = body;
 }
示例#6
0
 @Override
 public String toString(int j) {
   return String.format("while (%s) %s", expression.toString(), body.toString(j));
 }
示例#7
0
 public Marker setSymbol(Symbol pSymbol) {
   mSymbol = pSymbol.toString();
   return this;
 }