TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: JARI LAAKSONEN
date: 1997-03-28 21:58:00
subject: 05/11 Comment utilities for Java

========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 5/11 ==========
            if (ReadCh == '\n')
            {
                print ('\r');
            }
            print (ReadCh);
        }
    }
    //==================================================================
    /**
     * Print current line number.
     */
    protected void printLineNumber()
    {
        String str = "\n" + lines + ":\n";
        print (str);
    }
    //==================================================================
    /**
     * Write current state to output file.
     */
    protected void logState()
    {
        if (itsPrevState == itsState)
            return;
        String str = "\t\t\t\t| ";
        CPState st = new CPState (itsState);
        str += st.toString();
        str += "\n";
        print (str);
    }
   //====================================================================
    /**
     * The heart of the comment parser. A finite state machine which
     * does nothing else than determines the current state based on
     * the events.
     */
    private void processState (int theEvent)
    {
        if (itsState != CPState.InsideEscape)
            itsPrevState = itsState;
        // Escaped character.
        if (theEvent == CPEvent.FOUND_BACKSLASH)
        {
            itsState = CPState.InsideEscape;
            return;
        }
        switch (itsState)
        {
        case CPState.NormalInput:
            switch (theEvent)
            {
            case CPEvent.FOUND_QUOTE:
                itsState = CPState.InsideString;
                break;
            case CPEvent.FOUND_SINGLEQUOTE:
                itsState = CPState.InsideChar;
                break;
            case CPEvent.FOUND_SLASH:
                // to be investigated: begin of comment.
                itsState = CPState.BeginComment;
                break;
            }
            break;
        case CPState.InsideString:
            switch (theEvent)
            {
            case CPEvent.FOUND_QUOTE:
                // End of the string.
                itsState = CPState.NormalInput;
                break;
            }
            break;
        case CPState.InsideChar:
            switch (theEvent)
            {
            case CPEvent.FOUND_SINGLEQUOTE:
                // End of the character constant.
                itsState = CPState.NormalInput;
                break;
            }
            break;
        // We have found a '/', maybe this is a comment...
        case CPState.BeginComment:
            switch (theEvent)
            {
            case CPEvent.FOUND_SLASH:
                // Yes, it's a C++ comment.
                itsState = CPState.InCppComment;
                break;
            case CPEvent.FOUND_STAR:
                // Yes, it's a C comment.
                itsState = CPState.InCComment;
                break;
            default:
                // No, just a slash.
                itsState = CPState.NormalInput;
                break;
            }
            break;
        case CPState.InsideEscape:
            // Found backslash -- restore previous state.
            itsState = itsPrevState;
            break;
        case CPState.InCppComment:
            switch (theEvent)
            {
            case CPEvent.FOUND_CR:
            case CPEvent.FOUND_NL:
                // Newline is end of C++ comment.
                itsState = CPState.NormalInput;
                break;
            case CPEvent.FOUND_STAR:
                itsState = CPState.StarInCppComment;
                break;
            }
            break;
        case CPState.InCComment:
            switch (theEvent)
            {
            case CPEvent.FOUND_STAR:
                // to be investigated: end of comment.
                itsState = CPState.StarInCComment;
                break;
            }
            break;
        // '*' in C++ comment: action processors can use this to check
        // e.g. C comments inside C++ comment.
========== CSplit: End part 5/11 crc: 898b ==========
        // Albert                      email: jla@to.icl.fi
--- GoldED/2 2.50+
---------------
* Origin: Albert's Point/2 in Finland, Europe (2:221/360.20)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.