Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > C Programming Assignment:

Reply
Thread Tools

C Programming Assignment:

 
 
janconway
Guest
Posts: n/a
 
      02-24-2004
Hey, kinda bit lost with the lab assignment in college. any tips would be really appreciated.
basically we were given a flex file and we've to modify it to see if a string is a keyword or identifier within C itself. Just a bit lost as to where to start.
do i initialise a linked list to compare the two arrays or what?

 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      02-24-2004
janconway wrote:
>
> Hey, kinda bit lost with the lab assignment in college. any tips
> would be really appreciated. basically we were given a flex file
> and we've to modify it to see if a string is a keyword or
> identifier within C itself. Just a bit lost as to where to start.
> do i initialise a linked list to compare the two arrays or what?


Or what.

--
Chuck F ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

 
Reply With Quote
 
 
 
 
Grumble
Guest
Posts: n/a
 
      02-24-2004
janconway wrote:

> Hey, kinda bit lost with the lab assignment in college. any tips
> would be really appreciated. basically we were given a flex file
> and we've to modify it to see if a string is a keyword or
> identifier within C itself. Just a bit lost as to where to start.
> do i initialise a linked list to compare the two arrays or what?


The comp.compilers newsgroup seems more appropriate.

The following document might help:
http://www.tldp.org/HOWTO/Lex-YACC-HOWTO.html

 
Reply With Quote
 
GVK
Guest
Posts: n/a
 
      02-24-2004
janconway wrote:
> Hey, kinda bit lost with the lab assignment in college. any tips would be really appreciated.
> basically we were given a flex file and we've to modify it to see if a string is a keyword or identifier within C itself. Just a bit lost as to where to start.
> do i initialise a linked list to compare the two arrays or what?
>

If it is just a C programming assignment(no knowlegdge of compilers,
parsers etc. is assumed), you can take a two dimensional array
containing all the keywords,identifiers etc

key[][] = { "int","float",etc etc}

and compare with strcmp(input,key[i]) for all i. This was how I did MY
assignment

regards,
GVK

--
Happy Hacking!!!

 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      02-24-2004

"janconway" <(E-Mail Removed)> wrote in message
>
> basically we were given a flex file and we've to modify it to see if a
> string is a keyword or identifier within C itself. Just a bit lost as to
> where to start.
>

Start by writing this function

char *getidentifier(char *line, char *id)

Return NULL if you run to the end of the line without reading an identifier,
else return the position immediately past the id you just read. To make it
robust, set a max length for id.
>
> do i initialise a linked list to compare the two arrays or what?
>

You could use a linked list, but a simple array of all the keywords would be
easier. What is the output format?


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C (functional programming) VS C++ (object oriented programming) Joe Mayo C Programming 168 10-22-2007 01:00 AM
Can Your Programming Language Do This? Joel on functional programming and briefly on anonymous functions! Casey Hawthorne Python 4 08-04-2006 05:23 AM
Wireless PEAP/MSCHAPV2 client programming question Jim Howard Wireless Networking 6 07-02-2005 11:53 AM
systems programming versus application programming Matt Java 35 07-22-2004 08:10 AM
XSLT programming cameron Firefox 0 01-04-2004 10:51 PM



Advertisments