Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c file parser

Posted on 2004-10-28
15
Medium Priority
?
1,672 Views
Last Modified: 2012-08-13
I want the source code in C for C file parser.
0
Comment
Question by:chikucoder
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +4
15 Comments
 
LVL 6

Assisted Solution

by:Amritpal Singh
Amritpal Singh earned 200 total points
ID: 12432472
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
 
LVL 45

Assisted Solution

by:sunnycoder
sunnycoder earned 400 total points
ID: 12432759
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
 
LVL 1

Author Comment

by:chikucoder
ID: 12433620
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 86

Assisted Solution

by:jkr
jkr earned 400 total points
ID: 12434194
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
 
LVL 22

Accepted Solution

by:
grg99 earned 400 total points
ID: 12434821
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
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12441224
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
 
LVL 11

Expert Comment

by:avizit
ID: 12442245
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
 
LVL 1

Author Comment

by:chikucoder
ID: 12442281
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
 
LVL 11

Assisted Solution

by:avizit
avizit earned 200 total points
ID: 12442330
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
 
LVL 1

Author Comment

by:chikucoder
ID: 12442335
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
 
LVL 45

Expert Comment

by:sunnycoder
ID: 12442574
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
 
LVL 12

Assisted Solution

by:stefan73
stefan73 earned 400 total points
ID: 12443553
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
 
LVL 22

Expert Comment

by:grg99
ID: 12472460
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
 
LVL 1

Author Comment

by:chikucoder
ID: 12516703
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
 
LVL 1

Author Comment

by:chikucoder
ID: 12516704
I will distrubte points to all for the participation.

Chiku
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question