• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1698
  • Last Modified:

c file parser

I want the source code in C for C file parser.
0
chikucoder
Asked:
chikucoder
  • 5
  • 3
  • 2
  • +4
6 Solutions
 
Amritpal SinghCommented:
i hope u r familiar with parsing techniques and related stuff
then u can get help at the following links
 
http://www.programmersheaven.com/search/Download.asp?FileID=36435

http://www.thefreecountry.com/sourcecode/grammars.shtml
0
 
sunnycoderCommented:
hi Chikucoder :-),

Long time no see? ... What kind of parser are you looking for? Any constraints on memory etc ... ? Stefan asked one such question sometime ago ... check this link and see if you can use the links and the information ...

http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_21059753.html

Otherwise, gcc perhaps might contain the best source code available freely for a C parser ... It is also written mostly in C and assembly so you should be able to use it.

cheers
sunnycoder
0
 
chikucoderAuthor Commented:
Hi Sunny
 
Yah! Its been long time that hit any character in EE site!.........Coz
of work....
I went thorugh most of the links where in I saw bits and pieces of
parser,..
The one Im looking for is small parser model,with basic feature
implemented in c.
The link which u provided in case of stefan is abt c++ source code.
Pls provide me proper refrence  ,consider this as high priority.

:q!
C!
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
jkrCommented:
I'd recommend the GCC sources (http://directory.fsf.org/devel/compilers/gcc.html) - get them directly from ftp://ftp.gnu.org/gnu/gcc/gcc-3.4.0
0
 
grg99Commented:
Depending on what you want to do with this C parsting, the gcc code may be very useful, or a very poor choice.

If you just want to extract basic language tokens and keywords, all it takes is about 150 lines of code maximum.

If you want to also parse and understand and expand and handle trickier things, like macros and templates and trigraphs, then you need a whole lot more lines of code.

If you need a full syntactic scan, complete with namespaces, nested scopes, overriden operators identified, effective type computations, then you DO NEED most of the front half of a full compiler.

gcc code would be a poor choice for the easier tasks, as it IIRC involves about 288 files just for the simple stuff.
0
 
sunnycoderCommented:
I am still not very clear about what exactly you are looking for ... What all features/functionality do you desire to have in your parser ? Still, check these links .... and good luck

http://home.earthlink.net/~slkpg/
http://compilers.iecc.com/comparch/article/91-09-030
0
 
avizitCommented:
if you want lex and yacc grammar for ANSI C you can get from  

http://www.lysator.liu.se/c/ANSI-C-grammar-y.html   <-- YACC granmar
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html    <--  lex specification

LCC is a C compiler and as such includes a ANSI C Parser , this program is somwhat easier to undstand than sophisticated compilers like gcc

the source code is available from http://www.cs.princeton.edu/software/lcc/  though its better to buy the book too
0
 
chikucoderAuthor Commented:
Hi All,

Let me make it bit simpler,I need source code in c for basic Lexical anlyser for c file.Consider for a Demostartion purpose,No matter it dose'nt contain entire feature of Lexical analyser of gcc compiler.

Thanks in advance
chiku
0
 
avizitCommented:
for lexical analyser ansi.c.grammar.Z from

download  ftp://ftp.uu.net/usenet/net.sources/ansi.c.grammar.Z

unzip using

uncompress ansi.c.grammar.Z

edit the file  ansi.c.grammar  to delete everything before the line containing #!/bin/sh

sh ansi.c.grammar

you get a file scan.l
that contains a LEX specification for an ANSI C scanner

so type

lex scan.l

/** you may need to install lex/flex if its not there **/

so you wil end up with a file lex.yy.c

that isthe source code you need



0
 
chikucoderAuthor Commented:
Hi Sunny,

I sent a mail to <email-id removed by sunnycoder, Page Editor>,it bounced back to me.You have any other ID,send it to <email-id removed by sunnycoder, Page Editor>.

CHeers
Chiku
0
 
sunnycoderCommented:
hi Chiku,

use the experts-exchange id ... It works fine ... I am having some issues with the hotmail id :-(

Also, avoid posting email ids in threads ... they will be easily fished by spammers
0
 
stefan73Commented:
Hi chikucoder,
> I need source code in c for basic Lexical anlyser for c file
The C lexer should be very simple.

BTW: There is a full C grammar in the K&R book.

Cheers!

Stefan
0
 
grg99Commented:
You could also strip the guts out of any good C source cross referencer, they have to have a lexical scanner plus a mini-parser to handle local variables.  try:

http://www.gedanken.demon.co.uk/cxref/

0
 
chikucoderAuthor Commented:
I Appericiate each and every one who participated in this question,I got fed up of searching on web,So finally one night I sat finished it all,

Cheers
CHiku
0
 
chikucoderAuthor Commented:
I will distrubte points to all for the participation.

Chiku
0

Featured Post

KuppingerCole Reviews AlgoSec in Executive Report

Leading analyst firm, KuppingerCole reviews AlgoSec's Security Policy Management Solution, and the security challenges faced by companies today in their Executive View report.

  • 5
  • 3
  • 2
  • +4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now