[TAG] Re: PROBLEM

mso@oz.net mso
Fri Nov 19 22:19:43 MSK 2004


Arnold wrote:
> but i am having problems compiling and debugging the following program ...
> can you please help me out with its solution.
>
> using UNIX filters and awk to write a shell script to filter out comment
> statements in a C program
>
> a shell script to count the number of parentheses and braces in a C
> program
>
>  a shell script to recognize function calls in a C program
>
>  a shell script to generate code to do profiling of a C program (to insert
> counters to the C program)
>
> using filter or just  grep, sed and awk)
>
> hoping for some guidence
> sincerely
> Amod Damle
> (ILLINOIS INSTITUTE OF TECHNOLOGY-CHICAGO)

The first thing you should see is the TAG Posting Guidelines
http://linuxgazette.net/tag/ask-the-gang.html
in the FAQ section.  There you'll see we don't do people's homework for
them.  How do we know it's homework?  You don't want to do a useful task:
who cares how many braces a C program has?  You choose the tools first and
then the strategy, and you insist on using kludgey tools.  If I really
wanted to count braces, I would write a Python program.

``
#!/usr/bin/env python
"""count-braces.py

Usage: count-braces.py <filename
Print the number of {}() characters in the input file.
"""
import re, sys

braceRx = re.compile( R"[{}()]" )
text = sys.stdin.read()
hits = braceRx.findall(text)
print len(hits)
''






More information about the TAG mailing list