blob: 73883f6f6120808ddffe9951f2ddeed5ce5cc17a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
%{
#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);
}
|