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...
lex 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;} | ';' { %%
any help would be appreciatedCode:%{ #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]; %%![]()



LinkBack URL
About LinkBacks



