[Ilugc] Need to Learn ply or pycparser

  • From: thescriptdevil@xxxxxxxxx (Ashok Gautham)
  • Date: Tue Feb 9 16:39:37 2010

On Mon, Feb 8, 2010 at 10:51 PM, Balachandar <balachandarlinks@xxxxxxxxx>
wrote:

Hi guys,
   As a part of my project i need to parse a "c source code" into tokens.I
need
to process the tokens to identify some predefined patterns.I searched in
google
and got some suggestions about pycparser and ply.

ply looks like a general purpose lex/yacc replacement...
pycparser uses ply internally and generates the AST.

I am doubtful if you need pycparser. Take the source and
use only the lexer... You do not need a parser to tokenize.

This is a lex version of the C language
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html

Do the values 'returned' contain enough info for you? If so,
lex is the tool.

---
Ashok `ScriptDevil` Gautham

Other related posts: