Logo Search packages:      
Sourcecode: jasmin-sable version File versions  Download package

static void java_cup::Main::check_unused (  )  [inline, static, protected]

Check for unused symbols. Unreduced productions get checked when tables are created.

Definition at line 448 of file Main.java.

References java_cup::terminal::EOF, java_cup::terminal::error, java_cup::symbol::name(), and java_cup::symbol::use_count().

Referenced by main().

    {
      terminal term;
      non_terminal nt;

      /* check for unused terminals */
      for (Enumeration t = terminal.all(); t.hasMoreElements(); )
      {
        term = (terminal)t.nextElement();

        /* don't issue a message for EOF */
        if (term == terminal.EOF) continue;

        /* or error */
        if (term == terminal.error) continue;

        /* is this one unused */
        if (term.use_count() == 0)
          {
            /* count it and warn if we are doing warnings */
            emit.unused_term++;
            if (!emit.nowarn) 
            {
              System.err.println("Warning: Terminal \"" + term.name() + 
                             "\" was declared but never used");
              lexer.warning_count++;
            }
          }
      }

      /* check for unused non terminals */
      for (Enumeration n = non_terminal.all(); n.hasMoreElements(); )
      {
        nt = (non_terminal)n.nextElement();

        /* is this one unused */
        if (nt.use_count() == 0)
          {
            /* count and warn if we are doing warnings */
            emit.unused_term++;
            if (!emit.nowarn) 
            {
              System.err.println("Warning: Non terminal \"" + nt.name() + 
                             "\" was declared but never used");
              lexer.warning_count++;
            }
          }
      }

    }


Generated by  Doxygen 1.6.0   Back to index