using YACC and lex to make your own shell...
anyone know of any links that could help me with this? I've read the man pages on YACC and lex and im still a bit lost...here's what i have so far..
YACC part...
Code:
%{
#include <stdio.h>
int at_end = 0;
extern int yychar;
%}
%token CD GETENV SETENV SETPROMPT EXIT SYSTEM WORD
%start cmd
%%
cmd: CD WORD {chdir($2.sval); YYACCEPT;}
| GETENV {getenv(); YYACCEPT;}
| SETENV {setenv(); YYACCEPT;}
| EXIT {exit(1); YYACCEPT;}
| ';' {
%%
lex part:
Code:
%{
#nclude "y.tab.h"
extern int yylval;
%}
%%
cd return CD;
$[A-Za-z]+ return GETENV;
setenv return SETENV;
setprompt return SETPROMPT;
exit return EXIT;
[a-zA-Z\/.] {strcpy(yyval.sval, yytext) return WORD;}
. return yytext[0];
%%
any help would be appreciated :)