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
Solved

tokenize sourcecode, compiler design

Posted on 2004-04-26
9
414 Views
Last Modified: 2010-04-15
in which tokens would a C compiler tokenize this little func?

int max(int i, int j)
/* this is a comment */
{
  return i > j ? i : j;
}
0
Comment
Question by:jakl
  • 4
  • 3
9 Comments
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10918676
homework ?
0
 

Author Comment

by:jakl
ID: 10918690
should have known...
answer or dont, if i told you it was not homework you wouldnt believe it anyway.
0
 
LVL 45

Expert Comment

by:sunnycoder
ID: 10918863
jakl,

Please realize that experts are here to provide solutions and they do not derive pleasure out of declining to answer questions.
Your profile says that you are a student. The question is simple and homework like and unfortunately your reply is not very convincing.

Study and reasearch is an integral part of learning. I am afraid you will have to do your homework yourself. However, if you get stuck on something specific, ask here.

sunnycoder
0
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
LVL 2

Expert Comment

by:anupvijay
ID: 10919563
Hey Jakl,
Don't be disappointed....
Just tell us what you have understood of the question and what answer you have come out with....
All of us here will really help you if you are really stuck.
Cheers.
0
 

Author Comment

by:jakl
ID: 10926438
heh, disappointed? i think not. after all, this is just a question in some forum.

just for the sake of it..  the question is from an ebook in pdf format(one file per chapter). after every chapter there is a summary in form of some exercises. unfortunately the answer-appendices are missing.

well, these are the tokens i came up with and just wanted to get checked:

identifiers: max i j
operators: ( ) = > ? :
punctuators: { } , ;
keywords: int return
constants: -
string constants: -

nevermind if they are correct or not. i really dont know why im explaining myself here...
0
 

Author Comment

by:jakl
ID: 10938655
well then, lets discuss.
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 125 total points
ID: 10967146
int max(int i, int j)
/* this is a comment */
{
  return i > j ? i : j;
}

identifiers: max i j        ........ right
operators: ( ) = > ? :    .... there was no =
punctuators: { } , ;        ..... right
keywords: int return       .... right
constants: -
string constants: -

lexer gets to see the comments too .. though it does not form tokens out of them for further processing ....

you were pretty good

cheers
0
 

Author Comment

by:jakl
ID: 10968887
thanks.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
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…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

789 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