parsing - C source code lexical parser in Java -


i need lexical parser parse c source codes , have using java language. researched , saw antlr , javacc. of these parsers better use , why? or have other parser recommend?

answers appreciated. thanks.

a lexer breaks input stream tokens. don't count incomplete purpose of computing simple metrics.

if want differentiate "functions" "variables" you'll need kind of parser check sequences of tokens determine represent (e.g., "a variable declaration, use, or function declaration"). can build ad hoc parser may satisfy counting needs @ price of making occasional mistakes, or can real parser , right. (parsing c variable declaration lot harder looks @ first glance; pretty arcane syntax).

if homework, or real problem , don't care if answer wrong, lexer generator , ad hoc parsing code enough.

if want accurately, you'll need preprocessor , parser, , you'd better (implicitly including lexer).


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -