Solved

tokenize sourcecode, compiler design

Posted on 2004-04-26
9
412 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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 structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

785 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