TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: ALL
from: JARI LAAKSONEN
date: 1997-03-28 21:57:00
subject: 02/16 Comment utilities

========== CSplit: Version 2.0 ==========
========== CSplit: Begin part 2/16 ==========
    unsigned long getCodeLines()        { return code_lines; }
    unsigned long getCppComments()      { return cpp_comments; }
    unsigned long getCommentLines()     { return cmt_lines; }
    int getOpenComment()                { return open_comment; }
    int getCloseComment()               { return close_comment; }
    unsigned long getTotCppComments()   { return tot_cpp_comments; }
    unsigned long getTotCommentLines()  { return tot_cmt_lines; }
    unsigned long getTotLines()         { return tot_lines; }
    unsigned long getTotCodeLines()     { return tot_code_lines; }
    void reset();
    void sumTotals();
protected:
    virtual void processActions (Event theEvent);
private:
    unsigned long   code_lines;
    unsigned long   cpp_comments;
    unsigned long   cmt_lines;
    int             open_comment;
    int             close_comment;
    unsigned long   tot_cpp_comments;
    unsigned long   tot_cmt_lines;
    unsigned long   tot_lines;
    unsigned long   tot_code_lines;
};
#endif // _CMTCOUNT_H_
========== CSplit: End file CMTCOUNT.H ==========
========== CSplit: Begin file CMTPARSR.H ==========
/*
 * CMTPARSR.H
 * Base class: comment parser.
 *
 * ver 1.0, 30 Jun 1996
 *
 * ver 1.1, 10 Dec 1996
 *   added logState().
 *
 * ver 1.2, 28 Mar 1997
 *   Some method names changed.
 *
 * Public domain by:
 *   Jari Laaksonen
 *   Arkkitehdinkatu 30 A 2
 *   FIN-33720 Tampere
 *   FINLAND
 *
 *   Fidonet : 2:221/360.20
 *   Internet: jla@to.icl.fi
 */
#ifndef _CMTPARSR_H_
#define _CMTPARSR_H_
#include 
class CommentParser
{
public:
    enum State {
        NormalInput,       //  0
        InsideString,      //  1
        InsideChar,        //  2
        BeginComment,      //  3
        InsideEscape,      //  4
        InCppComment,      //  5
        InCComment,        //  6
        StarInCppComment,  //  7
        StarInCComment     //  8
    };
    enum Event {
        ANY_CHAR,          //  0
        FOUND_BACKSLASH,   //  1
        FOUND_NL,          //  2
        FOUND_QUOTE,       //  3
        FOUND_SINGLEQUOTE, //  4
        FOUND_SLASH,       //  5
        FOUND_STAR,        //  6
        FOUND_WHITESPACE,  //  7
        END_OF_FILE        //  8
    };
    CommentParser (State initState = NormalInput)
        : itsState(initState)
        , lines(0)
        , bOutFile(0)
    { }
    virtual ~CommentParser() { }
    int init (int argc, char **argv);
    int init (char *file, State initState = NormalInput);
    void unInit();
    int run();
    unsigned long getLines()     { return lines; };
    int getLastState()           { return itsState; };
    void print (const char *str) { fputs (str, OutFile); }
protected:
    virtual void processActions (Event theEvent) = 0;
    void print (char ch)         { fputc (ch, OutFile); }
    void changeChar (int ch)     { ReadCh = ch; }
    int getReadChar();
    void printChar();
    void printLineNumber();
    void logState();
    State   itsState;
    State   itsPrevState;
private:
    void processState (Event theEvent);
    Event getEvent();
    int readChar();
    unsigned long  lines;
    int     bOutFile;
    int     ReadCh;
    FILE   *InFile,
           *OutFile;
};
#endif // _CMTPARSR_H_
========== CSplit: End file CMTPARSR.H ==========
========== CSplit: Begin file CMTREMOV.H ==========
/*
 * CMTREMOV.H
 * Comment remover class.
 *
 * ver 1.0, 30 Jun 1996
 *
 * ver 1.1, 28 Mar 1997
========== CSplit: End part 2/16 crc: b0e0 ==========
        // 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™.