Hiya AWK gurus!
I'm trying analyze C++ files, counting c-style casts and class definitions (possible more stuff in the future).
All in all it works fairly well, but I have some problems.
1. Line by line parsing
I have to make hacks to detect line breaked statements, like
where { is on a new line.
I still want to differentiate a statement like
(which should be ignored) from
Which should be detected. Any clever way to accomplish this (Is awk perhaps not suitable for this kind of things - I dont wanna write a full c++ parser ;-) )?
2. c-style cast detection
This is my c-style detection pattern:
When detecting c-style cast I have some problem with statements like
Any cool way to ignore those?
It'd also be relly neat to skip commented sections entirely. // comments are manageble;I can just check if a // is preceding the first (, but what about /*...*/ sections? Is that even feasible?
Any ideas are welcome.
Using some old awk.exe (yes - we're talking windows here) from the MKS toolkit)
Thank you
/Per
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."
I'm trying analyze C++ files, counting c-style casts and class definitions (possible more stuff in the future).
All in all it works fairly well, but I have some problems.
1. Line by line parsing
I have to make hacks to detect line breaked statements, like
Code:
class Foo
{
I still want to differentiate a statement like
Code:
class Foo;
Code:
class Foo : public Bar
{
...
class Foo {
...
class Foo
{
2. c-style cast detection
This is my c-style detection pattern:
Code:
#--- Match c cast ---
# (Identifier*) Identifier
# With optional * and optional whitespaces here and there
/\([ \t]*[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\**[ \t]*\)[ \t]*[a-zA-Z_][a-zA-Z0-9_]*/ {
When detecting c-style cast I have some problem with statements like
Code:
void getBar() { if (foo) return bar; }
It'd also be relly neat to skip commented sections entirely. // comments are manageble;I can just check if a // is preceding the first (, but what about /*...*/ sections? Is that even feasible?
Any ideas are welcome.
Using some old awk.exe (yes - we're talking windows here) from the MKS toolkit)
Thank you
/Per
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."