GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 02-Aug-2004, 21:06
nkhambal nkhambal is offline
Regular Member
 
Join Date: Jul 2004
Location: CA USA
Posts: 313
nkhambal is a jewel in the roughnkhambal is a jewel in the rough

Need help in writing a parser program


Hi,

I want to write a parser program which will take commands typed by users and will parse it against a parse tree and if command is syntactically correct,will return a a pointer to a function which will functionally execute the command.

I can write a functions to collect the commands and break them separately and store them in an array.I need help in developing a parser function which will parse the command for syntax against a structure conatining the valid command syntax or something similar to that and should return a pointer to a function which will execute the command.The function pointer can also be a part of the parse tree structure.

A typical command would be like "add user" or "add group"
the parse structure would look something like one below.

CPP / C++ / C Code:
struct {
char *c1;
char *c2;
int (*func_ptr)();
}
cli[100]={
"add","user",<function_ponter_add_user_function>,
"add","group",<function_ponter_add_group_function>};

so parser function will return function_pointer.

So the question is how to write a function that returns the pointer to another function and how to use this pointer to call another function?

Any help will be appriciated.

Thanks,
 
 

Recent GIDBlogMeeting the local Iraqis by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help with a C program (Long) McFury C Programming Language 3 29-Apr-2004 20:06
Modify a C program ayoub C Programming Language 3 15-Mar-2004 11:34
Please Help, problems writing newbie c program soulfly C Programming Language 14 04-Mar-2004 15:16
Please Help, problems writing c program REVISED soulfly C Programming Language 6 03-Mar-2004 13:57
Please Help, problems writing newbie C program ReREVISED soulfly C Programming Language 0 02-Mar-2004 22:01

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:20.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.