Hi Phil, Thank you for the response and time, regarding what you said: **GDB** I have tried GDB, my gdb skills are weak trying to learn how to use it better, but I am still not sure what is going on. I will include the gdb output at the end of the email which include the verbose Bison output.
**String Dumps with Lex:** I think that is what I am doing: [a-zA-Z/0-9\-_\.]+ { yylval.string=strdup(yytext); return(WORD); } **Using Union** I am using Union and types, here they are: %union { char * string; struct node * args; struct ext_cmd * cmd_w_args; } %token <string> CD WORD PWD EXIT EQUALS %token ERROR HELP NEWLINE SEMI PVAR GT %type <args> arg_list %type <string> variable_assignment redirect %type <cmd_w_args> external_cmd **Malloc Tip** Seems smart, going to implemement when I get a chance. **Memory Problems with Yacc/Lex** """Your not going to be able to fault memory corruption or problems on bison or lex""" My fault for not being clear, I am not trying to blame Bison at all. I figure it is myfault, I just meant I wasn't quite sure how things like $$ work, and if I am abusing something by do something like &($1) ***"Not going to debug this for you", and a little more targeted information*** Well, I can always hope ;-) I am just a little stuck, becuase I don't get why my execute_command function, providing my external_cmd (which is typed cmd_w_args) as an argument, would behave different depending on what rule it is called from ( Works when I call it from 'command', but not from 'redirect'). They both seem to get reduced the same up the same rule: line 109 (arg_list: WORD) to line 85( external_cmd: WORD arg_list). **GDB Output with Bison debug** Reading a token: kbsh:/home/kbrandt/projects/svn/practicalc/simpleShell/preConcepts/chdir_and_printdir_lex_and_yacc% ls /home Next token is token WORD () Reducing stack by rule 4 (line 49): -> $$ = nterm line () Stack now 0 Entering state 2 Next token is token WORD () Shifting token WORD () Entering state 6 Reading a token: Next token is token WORD () Shifting token WORD () Entering state 24 Reading a token: Next token is token NEWLINE () Reducing stack by rule 21 (line 109): $1 = token WORD () -> $$ = nterm arg_list () Stack now 0 2 6 Entering state 26 Reducing stack by rule 18 (line 85): $1 = token WORD () $2 = nterm arg_list () -> $$ = nterm external_cmd () Stack now 0 2 Entering state 16 Next token is token NEWLINE () Reducing stack by rule 11 (line 70): $1 = nterm external_cmd () Breakpoint 1, execute_command (cmd=0x941a088, redirection=0) at command.c:18 18 struct node ** node_pp = cmd->args_pp; (gdb) print *(cmd->args_pp) $6 = (struct node *) 0x941a078 (gdb) print *(cmd->args_pp)->val $7 = 47 '/' Reading a token: kbsh:/home/kbrandt/projects/svn/practicalc/simpleShell/preConcepts/chdir_and_printdir_lex_and_yacc% ls /home > foo Next token is token WORD () Reducing stack by rule 4 (line 49): -> $$ = nterm line () Stack now 0 Entering state 2 Next token is token WORD () Shifting token WORD () Entering state 6 Reading a token: Next token is token WORD () Shifting token WORD () Entering state 24 Reading a token: Next token is token GT () Reducing stack by rule 21 (line 109): $1 = token WORD () -> $$ = nterm arg_list () Stack now 0 2 6 Entering state 26 Reducing stack by rule 18 (line 85): $1 = token WORD () $2 = nterm arg_list () -> $$ = nterm external_cmd () Stack now 0 2 Entering state 16 Next token is token GT () Shifting token GT () Entering state 29 Reading a token: Next token is token WORD () Shifting token WORD () Entering state 33 Reducing stack by rule 8 (line 60): $1 = nterm external_cmd () $2 = token GT () $3 = token WORD () Redirecting stdout of ls to foo DEBUG: GT Breakpoint 1, execute_command (cmd=0x9b80088, redirection=0) at command.c:18 18 struct node ** node_pp = cmd->args_pp; (gdb) print cmd->args_pp $4 = (struct node **) 0xbfd4cc40 (gdb) print *(cmd->args_pp) $5 = (struct node *) 0x9b80068 (gdb) print *(cmd->args_pp)->val Cannot access memory at address 0x6d6f682f Thanks again, Kyle _______________________________________________ help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison