473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

C Programming Assignment:

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?

Nov 14 '05 #1
4 1594
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 (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

Nov 14 '05 #2
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

Nov 14 '05 #3
GVK
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!!!

Nov 14 '05 #4

"janconway" <ja*******@hotmail.com> 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?
Nov 14 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bo Xu | last post by:
Object of Combination By Bo Xu Introduction A combination of n things, taken s at a time, often referred as an s-combination out of n, is a way to select a subset of size s from a given set of...
12
by: John Fullman | last post by:
I do this in several large classes to avoid rewriting copy ctr code. It seems to work okay, but I was wondering if I might be shooting myself in the foot later... I can't think of anything wrong...
134
by: evolnet.regular | last post by:
I've been utilising C for lots of small and a few medium-sized personal projects over the course of the past decade, and I've realised lately just how little progress it's made since then. I've...
7
by: Michael | last post by:
Hey, I'm, I guess, an itermediate programmer and I have a question about learning any programming language. I understand that as a programmer you're going to probably constantly be re-writing code...
5
by: David Delony | last post by:
I've hacked on shell and Perl and now I want to get seriously into C. I got bogged down in K & R, but I realized that I need to know more about the low-level computing stuff. I'd like some pointers...
23
by: Dexter | last post by:
My site is home to series of quizzes ranging from Accounting, Business, Math to programming languages. These are multiple choice type questions and you get a score card at end. For C language, ...
1
by: trav4 | last post by:
I have an assignment for school and I am new to programming. For the assignment I need to make a survey with at least 4 choices that uses 2 arrays. It must be done in a console application. How...
2
by: mshroom12 | last post by:
I am having trouble with the following project on hand. I use Eclipse to do my work in Java. This is what I'm supposed to complete. Date Validation In this exercise you will write a program...
5
by: mangoxoxo | last post by:
Hey I'm not sure if this is where I should be asking this but I'm going to ask anyway. I'm doing an assignment for my Intro to Comp Programming class. This is the assignment: Define a class...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.