Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Parsing l- and r-values
Hi,
I have to write a simplified static analyzer for ANSI C, able (among
other things) to identify global variables usage (i.e. which global
variables are changed, and which are used into expressions) for each
function. For example:

extern int a;
extern int b;
foo()
{
..
a = b++/2;
..
}

In this case, I need to detect that either a and b are changed by
foo(), and b is used into an expression. In a first time I can ignore
"complicated" cases as indirect assignments:

foo()
{
int *d = &c;
*d = 3;       /* c is changed */
}

I have very little experience with parsers; I've used sometimes
flex/yacc for some trivial tasks, nothing more complicated than the
usual didactic examples. Before I start, I'd like to have your opinion
on the complexity of this task. Do you think it's possible to use
these lexers/parsers to solve the problem? All of the yacc C grammars
I've found don't make such distinction as "l-value" or "r-value", but
I suppose I can slightly modify the grammar. Or I need something
different?

Can you point me at some document/example I may find useful?

Thank you!
[I think it's more common to check for l-values in semantic code, not
in the grammar. -John]

Report this thread to moderator Post Follow-up to this message
Old Post
AI
08-23-04 09:02 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Compilers archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:46 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.