%{ #include "syntax.tab.h" void yyerror(const char *s); %} %option noyywrap %% [\t ]+ { /* Ignore whitespace */ } "\n" { return NEWLINE; } "\\\n" { printf("> "); } "|" { return PIPE; } "&&" { return AND; } "||" { return OR; } "<" { return REDIRECT_IN; } ">" { return REDIRECT_OUT; } ">>" { return APPEND; } "&" { return BACKGROUND; } [0-2]">"&[0-2] { yylval.str = strdup(yytext); return FD_REDIRECT; } \"[^\"]*\" { yylval.str = strdup(yytext); return STRING; } [a-zA-Z0-9_\-\/\*.]+ { yylval.str = strdup(yytext); return WORD; } "(" { return LPAREN; } ")" { return RPAREN; } %% void yyerror(const char *s) { fprintf(stderr, "error: %s\n", s); }