Package java.lang

Examples of java.lang.Integer$ReverseNibbles


      return (new String("--"));
    }

  index = m_spec.m_nfa_states.indexOf(state);
 
  return ((new Integer(index)).toString());
      }
View Full Code Here


      {
  int elem;
  CNfa nfa;
  int size;
  Enumeration states;
  Integer index;
  int i;
  int j;
  int vsize;
  String state;
    
  System.out.println("--------------------- NFA -----------------------");
 
  size = m_spec.m_nfa_states.size();
  for (elem = 0; elem < size; ++elem)
    {
      nfa = (CNfa) m_spec.m_nfa_states.elementAt(elem);
     
      System.out.print("Nfa state " + plab(nfa) + ": ");
     
      if (null == nfa.m_next)
        {
    System.out.print("(TERMINAL)");
        }
      else
        {
    System.out.print("--> " + plab(nfa.m_next));
    System.out.print("--> " + plab(nfa.m_next2));
   
    switch (nfa.m_edge)
      {
      case CNfa.CCL:
        printccl(nfa.m_set);
        break;

      case CNfa.EPSILON:
        System.out.print(" EPSILON ");
        break;
       
      default:
        System.out.print(" " + interp_int(nfa.m_edge));
        break;
      }
        }

      if (0 == elem)
        {
    System.out.print(" (START STATE)");
        }
     
      if (null != nfa.m_accept)
        {
    System.out.print(" accepting "
         + ((0 != (nfa.m_anchor & CSpec.START)) ? "^" : "")
         + "<"
         + (new String(nfa.m_accept.m_action,0,
                 nfa.m_accept.m_action_read))
         + ">"
         + ((0 != (nfa.m_anchor & CSpec.END)) ? "$" : ""));
        }

      System.out.println();
    }

  states = m_spec.m_states.keys();
  while (states.hasMoreElements())
    {
      state = (String) states.nextElement();
      index = (Integer) m_spec.m_states.get(state);

      if (CUtility.DEBUG)
        {
    CUtility.ASSERT(null != state);
    CUtility.ASSERT(null != index);
        }

      System.out.println("State \"" + state
             + "\" has identifying index "
             + index.toString() + ".");
      System.out.print("\tStart states of matching rules: ");
     
      i = index.intValue();
      vsize = m_spec.m_state_rules[i].size();
     
      for (j = 0; j < vsize; ++j)
        {
    nfa = (CNfa) m_spec.m_state_rules[i].elementAt(j);
View Full Code Here

      {
  int start_state;
  int count_state;
  SparseBitSet states;
  String name;
  Integer index;
  int i;
  int size;
 
  if (CUtility.DEBUG)
    {
      CUtility.ASSERT(null != this);
      CUtility.ASSERT(null != m_outstream);
      CUtility.ASSERT(null != m_input);
      CUtility.ASSERT(null != m_tokens);
      CUtility.ASSERT(null != m_spec);
    }

  states = null;

  /* Skip white space. */
  while (CUtility.isspace(m_input.m_line[m_input.m_line_index]))
    {
      ++m_input.m_line_index;
   
      while (m_input.m_line_index >= m_input.m_line_read)
        {
    /* Must just be an empty line. */
    if (m_input.getLine())
      {
        /* EOF found. */
        return null;
      }
        }
    }

  /* Look for states. */
  if ('<' == m_input.m_line[m_input.m_line_index])
    {
      ++m_input.m_line_index;
    
      states = new SparseBitSet();

      /* Parse states. */
      while (true)
        {
    /* We may have reached the end of the line. */
    while (m_input.m_line_index >= m_input.m_line_read)
      {
        if (m_input.getLine())
          {
      /* EOF found. */
      CError.parse_error(CError.E_EOF,m_input.m_line_number);
      return states;
          }
      }

    while (true)
      {
        /* Skip white space. */
        while (CUtility.isspace(m_input.m_line[m_input.m_line_index]))
          {
      ++m_input.m_line_index;
     
      while (m_input.m_line_index >= m_input.m_line_read)
        {
          if (m_input.getLine())
            {
        /* EOF found. */
        CError.parse_error(CError.E_EOF,m_input.m_line_number);
        return states;
            }
        }
          }
       
        if (',' != m_input.m_line[m_input.m_line_index])
          {
      break;
          }

        ++m_input.m_line_index;
      }

    if ('>' == m_input.m_line[m_input.m_line_index])
      {
        ++m_input.m_line_index;
        if (m_input.m_line_index < m_input.m_line_read)
          {
      m_advance_stop = true;
          }
        return states;
      }

    /* Read in state name. */
    start_state = m_input.m_line_index;
    while (false == CUtility.isspace(m_input.m_line[m_input.m_line_index])
           && ',' != m_input.m_line[m_input.m_line_index]
           && '>' != m_input.m_line[m_input.m_line_index])
      {
        ++m_input.m_line_index;

        if (m_input.m_line_index >= m_input.m_line_read)
          {
      /* End of line means end of state name. */
      break;
          }
      }
    count_state = m_input.m_line_index - start_state;

    /* Save name after checking definition. */
    name = new String(m_input.m_line,
          start_state,
          count_state);
    index = (Integer) m_spec.m_states.get(name);
    if (null == index)
      {
        /* Uninitialized state. */
        System.out.println("Uninitialized State Name: " + name);
        CError.parse_error(CError.E_STATE,m_input.m_line_number);
      }
    states.set(index.intValue());
        }
    }
 
  if (null == all_states)
    {
View Full Code Here

           + "\".");
        }

      /* Enter new state name, along with unique index. */
      m_spec.m_states.put(new String(m_input.m_line,start_state,count_state),
        new Integer(m_spec.m_states.size()));
     
      /* Skip comma. */
      if (',' == m_input.m_line[m_input.m_line_index])
        {
    ++m_input.m_line_index;
View Full Code Here

    (
     )
      throws java.io.IOException
      {
  boolean saw_escape = false;
  Integer code;
 
  /*if (m_input.m_line_index > m_input.m_line_read) {
    System.out.println("m_input.m_line_index = " + m_input.m_line_index);
    System.out.println("m_input.m_line_read = " + m_input.m_line_read);
    CUtility.ASSERT(m_input.m_line_index <= m_input.m_line_read);
  }*/

  if (m_input.m_eof_reached)
    {
      /* EOF has already been reached,
         so return appropriate code. */

      m_spec.m_current_token = END_OF_INPUT;
      m_spec.m_lexeme = '\0';
      return m_spec.m_current_token;
    }

  /* End of previous regular expression?
     Refill line buffer? */
  if (EOS == m_spec.m_current_token
      /* ADDED */
      || m_input.m_line_index >= m_input.m_line_read)
      /* ADDED */
    {
      if (m_spec.m_in_quote)
        {
    CError.parse_error(CError.E_SYNTAX,m_input.m_line_number);
        }
     
      while (true)
        {
    if (false == m_advance_stop 
        || m_input.m_line_index >= m_input.m_line_read)
      {
        if (m_input.getLine())
          {
      /* EOF has already been reached,
         so return appropriate code. */
     
      m_spec.m_current_token = END_OF_INPUT;
      m_spec.m_lexeme = '\0';
      return m_spec.m_current_token;
          }
        m_input.m_line_index = 0;
      }
    else
      {
        m_advance_stop = false;
      }

    while (m_input.m_line_index < m_input.m_line_read
           && true == CUtility.isspace(m_input.m_line[m_input.m_line_index]))
      {
        ++m_input.m_line_index;
      }
   
    if (m_input.m_line_index < m_input.m_line_read)
      {
        break;
      }
        }
    }
 
  if (CUtility.DEBUG) {
    CUtility.ASSERT(m_input.m_line_index <= m_input.m_line_read);
  }

  while (true)
    {
      if (false == m_spec.m_in_quote
    && '{' == m_input.m_line[m_input.m_line_index])
        {
    if (false == expandMacro())
      {
        break;
      }
        
    if (m_input.m_line_index >= m_input.m_line_read)
      {
        m_spec.m_current_token = EOS;
        m_spec.m_lexeme = '\0';
        return m_spec.m_current_token;
      }
        }
      else if ('\"' == m_input.m_line[m_input.m_line_index])
        {
    m_spec.m_in_quote = !m_spec.m_in_quote;
    ++m_input.m_line_index;
   
    if (m_input.m_line_index >= m_input.m_line_read)
      {
        m_spec.m_current_token = EOS;
        m_spec.m_lexeme = '\0';
        return m_spec.m_current_token;
      }
        }
      else
        {
    break;
        }
    }

  if (m_input.m_line_index > m_input.m_line_read) {
    System.out.println("m_input.m_line_index = " + m_input.m_line_index);
    System.out.println("m_input.m_line_read = " + m_input.m_line_read);
    CUtility.ASSERT(m_input.m_line_index <= m_input.m_line_read);
  }

  /* Look for backslash, and corresponding
     escape sequence. */
  if ('\\' == m_input.m_line[m_input.m_line_index])
    {
      saw_escape = true;
    }
  else
    {
      saw_escape = false;
    }

  if (false == m_spec.m_in_quote)
    {
      if (false == m_spec.m_in_ccl &&
    CUtility.isspace(m_input.m_line[m_input.m_line_index]))
        {
    /* White space means the end of
       the current regular expression. */

    m_spec.m_current_token = EOS;
    m_spec.m_lexeme = '\0';
    return m_spec.m_current_token;
        }

      /* Process escape sequence, if needed. */
      if (saw_escape)
        {
    m_spec.m_lexeme = expandEscape();
        }
      else
        {
    m_spec.m_lexeme = m_input.m_line[m_input.m_line_index];
    ++m_input.m_line_index;
        }
    }
  else
    {
      if (saw_escape
    && (m_input.m_line_index + 1) < m_input.m_line_read
    && '\"' == m_input.m_line[m_input.m_line_index + 1])
        {
    m_spec.m_lexeme = '\"';
    m_input.m_line_index = m_input.m_line_index + 2;
        }
      else
        {
    m_spec.m_lexeme = m_input.m_line[m_input.m_line_index];
    ++m_input.m_line_index;
        }
    }
 
  code = (Integer) m_tokens.get(new Character(m_spec.m_lexeme));
  if (m_spec.m_in_quote || true == saw_escape)
    {
      m_spec.m_current_token = L;
    }
  else
    {
      if (null == code)
        {
    m_spec.m_current_token = L;
        }
      else
        {
    m_spec.m_current_token = code.intValue();
        }
    }

  if (CCL_START == m_spec.m_current_token) m_spec.m_in_ccl = true;
  if (CCL_END   == m_spec.m_current_token) m_spec.m_in_ccl = false;
View Full Code Here

  Enumeration names;
  String name;
  String def;
  Enumeration states;
  String state;
  Integer index;
  int elem;
  int size;

  System.out.println();
  System.out.println("\t** Macros **");
  names = m_spec.m_macros.keys();
  while (names.hasMoreElements())
    {
      name = (String) names.nextElement();
      def = (String) m_spec.m_macros.get(name);

      if (CUtility.DEBUG)
        {
    CUtility.ASSERT(null != name);
    CUtility.ASSERT(null != def);
        }

      System.out.println("Macro name \"" + name
             + "\" has definition \""
             + def + "\".");
    }

  System.out.println();
  System.out.println("\t** States **");
  states = m_spec.m_states.keys();
  while (states.hasMoreElements())
    {
      state = (String) states.nextElement();
      index = (Integer) m_spec.m_states.get(state);

      if (CUtility.DEBUG)
        {
    CUtility.ASSERT(null != state);
    CUtility.ASSERT(null != index);
        }

      System.out.println("State \"" + state
             + "\" has identifying index "
             + index.toString() + ".");
    }
     
  System.out.println();
  System.out.println("\t** Character Counting **");
  if (false == m_spec.m_count_chars)
View Full Code Here

  CDTrans dtrans;
  int last_transition;
  String str;
  CAccept accept;
  String state;
  Integer index;

  System.out.println("/*---------------------- DFA -----------------------");
 
  states = m_spec.m_states.keys();
  while (states.hasMoreElements())
    {
      state = (String) states.nextElement();
      index = (Integer) m_spec.m_states.get(state);

      if (CUtility.DEBUG)
        {
    CUtility.ASSERT(null != state);
    CUtility.ASSERT(null != index);
        }

      System.out.println("State \"" + state
             + "\" has identifying index "
             + index.toString() + ".");

      i = index.intValue();
      if (CDTrans.F != m_spec.m_state_dtrans[i])
        {
    System.out.println("\tStart index in transition table: "
           + m_spec.m_state_dtrans[i]);
        }
View Full Code Here

    return (idx<size);
      }
      public Object nextElement() {
    int r = bit + (offs[idx] << LG_BITS);
    advance();
    return new Integer(r);
      }
      private void advance() {
    while (idx<size) {
        while (++bit<BITS)
      if (0!=(bits[idx] & (1L<<bit)))
View Full Code Here

  CUtility.ASSERT(!a.get(0) && !a.get(1));
  java.util.Random r = new java.util.Random();
  java.util.Vector v = new java.util.Vector();
  for (int n=0; n<ITER; n++) {
      int rr = ((r.nextInt()>>>1) % RANGE) << 1;
      a.set(rr); v.addElement(new Integer(rr));
      // check that all the numbers are there.
      CUtility.ASSERT(a.get(rr) && !a.get(rr+1) && !a.get(rr-1));
      for (int i=0; i<v.size(); i++)
    CUtility.ASSERT(a.get(((Integer)v.elementAt(i)).intValue()));
  }
View Full Code Here

  /**
   * TODO
   */
  public static Integer[] createIntegerTestSet(int loopDepth) {
    Integer x[] = new Integer[20];
    for (int i = 0; i < x.length; i++) {
      x[i] = i;
    }
    return x;
  }
View Full Code Here

TOP

Related Classes of java.lang.Integer$ReverseNibbles

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.