Example #1
0
  public void importVocab(Grammar importG) {
    for (String tokenName : importG.tokenNameToTypeMap.keySet()) {
      defineTokenName(tokenName, importG.tokenNameToTypeMap.get(tokenName));
    }
    for (String tokenName : importG.stringLiteralToTypeMap.keySet()) {
      defineStringLiteral(tokenName, importG.stringLiteralToTypeMap.get(tokenName));
    }
    for (Map.Entry<String, Integer> channel : importG.channelNameToValueMap.entrySet()) {
      defineChannelName(channel.getKey(), channel.getValue());
    }
    //		this.tokenNameToTypeMap.putAll( importG.tokenNameToTypeMap );
    //		this.stringLiteralToTypeMap.putAll( importG.stringLiteralToTypeMap );
    int max = Math.max(this.typeToTokenList.size(), importG.typeToTokenList.size());
    Utils.setSize(typeToTokenList, max);
    for (int ttype = 0; ttype < importG.typeToTokenList.size(); ttype++) {
      maxTokenType = Math.max(maxTokenType, ttype);
      this.typeToTokenList.set(ttype, importG.typeToTokenList.get(ttype));
    }

    max = Math.max(this.channelValueToNameList.size(), importG.channelValueToNameList.size());
    Utils.setSize(channelValueToNameList, max);
    for (int channelValue = 0;
        channelValue < importG.channelValueToNameList.size();
        channelValue++) {
      maxChannelType = Math.max(maxChannelType, channelValue);
      this.channelValueToNameList.set(
          channelValue, importG.channelValueToNameList.get(channelValue));
    }
  }
Example #2
0
 public void importTokensFromTokensFile() {
   String vocab = getOptionString("tokenVocab");
   if (vocab != null) {
     TokenVocabParser vparser = new TokenVocabParser(this);
     Map<String, Integer> tokens = vparser.load();
     tool.log("grammar", "tokens=" + tokens);
     for (String t : tokens.keySet()) {
       if (t.charAt(0) == '\'') defineStringLiteral(t, tokens.get(t));
       else defineTokenName(t, tokens.get(t));
     }
   }
 }
Example #3
0
 public void importVocab(Grammar importG) {
   for (String tokenName : importG.tokenNameToTypeMap.keySet()) {
     defineTokenName(tokenName, importG.tokenNameToTypeMap.get(tokenName));
   }
   for (String tokenName : importG.stringLiteralToTypeMap.keySet()) {
     defineStringLiteral(tokenName, importG.stringLiteralToTypeMap.get(tokenName));
   }
   //		this.tokenNameToTypeMap.putAll( importG.tokenNameToTypeMap );
   //		this.stringLiteralToTypeMap.putAll( importG.stringLiteralToTypeMap );
   int max = Math.max(this.typeToTokenList.size(), importG.typeToTokenList.size());
   Utils.setSize(typeToTokenList, max);
   for (int ttype = 0; ttype < importG.typeToTokenList.size(); ttype++) {
     maxTokenType = Math.max(maxTokenType, ttype);
     this.typeToTokenList.set(ttype, importG.typeToTokenList.get(ttype));
   }
 }