gt:     if (_parsedFields.containsKey(fld)) {
context: package gen.core;
  
  import java.util.*;
  import irep.*;
  
  public class ProtocolParser {
    public ProtocolContext _context = new ProtocolContext();
    public IrepProtocol _protocol = null;
    public Vector _appParsers = new Vector();
    public Hashtable _parsedFields = new Hashtable();
    public Hashtable _parsedTlvs = new Hashtable();
    public Hashtable _parsedBlocks = new Hashtable();
    public Hashtable _withinChoose1 = new Hashtable();
    public Hashtable _withinTerm = new Hashtable();
    public int _pass = 1;
  
    public ProtocolParser(IrepProtocol prot, Vector app_parsers) {
      _protocol = prot;
      _context._protocol = prot;
      _appParsers = app_parsers;
    }
  
    // We'll use 1 to represent Normal block and -1 to represent
    // Block with SORT REVERSED attribute. So if a child node without
    // SORT REVERSED attribute present in a parent node with SORT
    // REVERSED
  
    public ProtocolContext Parse() {
      IrepBlock prot_block = null;
  
      prot_block = _protocol.getProtocolBlock();
  
      if (prot_block == null) {
        return _context;
      }
  
      _context._protocol = _protocol;
      _context._positiveList = new Hashtable();
      _context._negativeList = new Hashtable();
      _context._lookaheadBlocks = new Hashtable();
  
      _pass = 1;
      _parsedBlocks.clear();
      Gothrough(prot_block, 1);
  
      _pass = 2;
      _parsedBlocks.clear();
      Gothrough(prot_block, 1);
  
      return _context;
    }
  
    public void Gothrough(IrepBlock block, int parent_mark) {
      IrepComponent irep_comp = null;
      IrepSeq irep_seq = null;
      IrepSeqOf irep_seq_of = null;
      IrepSet irep_set = null;
      IrepSetOf irep_set_of = null;
      IrepPalBlock pal_block = null;
      IrepChoice irep_choice = null;
      IrepNode[] contents = null;
      int my_mark = 0;
  
      my_mark = parent_mark * GetMark(block);
  
      if (HasParsed(block, my_mark)) {
        return;
      }
  
      switch (block._blockType) {
        case IrepBlock.BLOCK_TYPE_PAL_BLOCK:
          pal_block = (IrepPalBlock) block;
          CheckPalBlock((IrepPalBlock) block);
          break;
      }
  
      contents = block.FlattenContents();
      Gothrough(contents, my_mark);
      CheckTerminatedBy((IrepTlv) block, my_mark);
    }
  
    public void Gothrough(IrepNode[] contents, int parent_mark) {
      int i = 0;
      IrepProtocol prot = null;
      IrepNode node = null;
      IrepBlockCall call = null;
      IrepNextLayerCall next_call = null;
      IrepBlock block = null;
      IrepField fld = null;
      int my_mark = 0;
  
      for (i = 0; i < contents.length; i++) {
        node = contents[i];
  
        switch (node._nodeType) {
          case IrepNode.IREP_NODE_TYPE_BLOCK:
            block = (IrepBlock) node;
            my_mark = parent_mark * GetMark(block);
            Gothrough(block, my_mark);
            break;
  
          case IrepNode.IREP_NODE_TYPE_BLOCK_CALL:
            call = (IrepBlockCall) node;
            prot = _context._protocol;
            block = prot._subTrees.get(new Integer(call._index));
            Gothrough(block, parent_mark);
            break;
  
          case IrepNode.IREP_NODE_TYPE_NEXT_LAYER_CALL:
            next_call = (IrepNextLayerCall) node;
            prot = _context._protocol;
            block = prot._subTrees.get(new Integer(next_call._index));
            Gothrough(block, parent_mark);
            break;
  
          case IrepNode.IREP_NODE_TYPE_FIELD:
            fld = (IrepField) node;
            GothroughField(fld);
            break;
  
          default:
            break;
        }
      }
    }
  
    public void CheckTerminatedBy(IrepTlv tlv, int parent_mark) {
      HashMap<Integer, IrepBlock> trees = null;
      IrepBlock called_block = null;
      int index = 0;
      int my_mark = 0;
  
      if (_pass == 2) {
        return;
      }
  
      if (_parsedTlvs.containsKey(tlv)) {
        return;
      }
  
      _parsedTlvs.put(tlv, tlv);
  
      trees = _protocol._subTrees;
  
      if (tlv._thenTermBlockCall != null) {
        index = tlv._thenTermBlockCall._index;
        called_block = trees.get(new Integer(index));
        _withinTerm.put(called_block, called_block);
  
        my_mark = parent_mark * GetMark(called_block);
        Gothrough(called_block, my_mark);
      }
  
      if (tlv._elseTermBlockCall != null) {
        index = tlv._elseTermBlockCall._index;
        called_block = trees.get(new Integer(index));
        _withinTerm.put(called_block, called_block);
  
        my_mark = parent_mark * GetMark(called_block);
        Gothrough(called_block, my_mark);
      }
    }
  
    public void CheckPalBlock(IrepPalBlock block) {
      PalBlockParser parser = null;
      int i = 0;
      IrepNode node = null;
      IrepBlock called_block = null;
      IrepBlockCall call = null;
      HashMap<Integer, IrepBlock> sub_trees = null;
  
      if (_pass == 2) {
        return;
      }
  
      if (_context._palBlockContexts.containsKey(block)) {
        return;
      }
  
      parser = new PalBlockParser(_context._lookaheadBlocks);
      _context._palBlockContexts.put(block, parser.BuildLookaheadPath(_protocol, block));
  
      sub_trees = _protocol._subTrees;
  
      // Currently, only IrepPalBlock contains CHOOSE attribute
  
      if (block._chooseType == IrepPalBlock.CHOOSE_1) {
        for (i = 0; i < block._contents.length; i++) {
          node = block._contents[i];
  
          if (node._nodeType == IrepNode.IREP_NODE_TYPE_BLOCK_CALL) {
            call = (IrepBlockCall) node;
            called_block = sub_trees.get(new Integer(call._index));
            _withinChoose1.put(called_block, called_block);
          }
        }
      }
    }
  
    public void GothroughField(IrepField fld) {
      int i = 0;
      AppParser parser = null;
  
      if (_pass == 2) {
        return;
      }
  
  