I am just learning flex / bison and I am writing my own shell with it.  I am
trying to figure out a good way to do variable interpolation. My initial
approach to this was to have flex scan for something like ~ for my home
directory, or $myVar , and then set what the yyval.string to what is
returned using a look up function. My problem is that this doesn't help me
when text appears as one token:

kbsh:/home/kbrandt% echo ~
/home/kbrandt
kbsh:/home/kbrandt% echo ~/foo
/home/kbrandt /foo
kbsh:/home/kbrandt%

The lex definition I have for variables:

\$[a-zA-Z/0-9_]+    {
    yylval.string=return_value(&variables, (yytext + sizeof(char)));;
    return(WORD);
}

Then in my Grammar, I have things like:
chdir_command:
    CD WORD { change_dir($2); }
    ;

Anyone know of a good way to handle this sort of thing? Am I going about
this wrong?

Thank you,
Kyle
_______________________________________________
help-bison@gnu.org http://lists.gnu.org/mailman/listinfo/help-bison

Reply via email to