C Programming Assignment:

Discussion in 'C Programming' started by janconway, Feb 24, 2004.

  1. janconway

    janconway Guest

    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?
    janconway, Feb 24, 2004
    #1
    1. Advertising

  2. janconway

    CBFalconer Guest

    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 () ()
    Available for consulting/temporary embedded and systems.
    <http://cbfalconer.home.att.net> USE worldnet address!
    CBFalconer, Feb 24, 2004
    #2
    1. Advertising

  3. janconway

    Grumble Guest

    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
    Grumble, Feb 24, 2004
    #3
  4. janconway

    GVK Guest

    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) for all i. This was how I did MY
    assignment :)

    regards,
    GVK

    --
    Happy Hacking!!!
    GVK, Feb 24, 2004
    #4
  5. janconway

    Malcolm Guest

    "janconway" <> 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?
    Malcolm, Feb 24, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chessc4c6
    Replies:
    9
    Views:
    480
    Old Wolf
    Mar 8, 2005
  2. nagy
    Replies:
    36
    Views:
    1,002
    Terry Reedy
    Jul 20, 2006
  3. Chris
    Replies:
    34
    Views:
    1,513
  4. ajim
    Replies:
    3
    Views:
    254
  5. ajim
    Replies:
    0
    Views:
    243
Loading...

Share This Page