#/urs/bin/env python

from __future__ import with_statement

import optparse
import os
import sys


if __name__ == '__main__':
    parser = optparse.OptionParser('%prog [options]')

    parser.add_option('-f', '--file',
                      action='store', dest='input',
                      help='Parse GTK-Doc comment blocks from the specified file')

    options, args = parser.parse_args(sys.argv)
    if not options.input:
        raise SystemExit('missing input file')
    elif not os.path.isfile(options.input):
        raise SystemExit('%s is not a file' % (options.input, ))

    in_comment = False
    lineno = 1
    with open(options.input, 'rU') as f:
        c1 = f.read(1)
        if c1:
            #not EOF
            if c1 == '\n':
                lineno += 1
            c2 = f.read(1)

            while True:
                if c1 == '/' and c2 == '*' and not in_comment:
                    in_comment = True
                    print(lineno)

                if c1 == '*' and c2 == '/' and in_comment:
                    in_comment = False

                c1 = c2
                c2 = f.read(1)
                if not c2:
                    #EOF
                    break
                if c2 == '\n':
                    lineno += 1
