aboutsummaryrefslogtreecommitdiffstats
path: root/lex.l
blob: 230a5b03fa118d543eafa022f8eea60c6b3b0d86 (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
%{
#include "syntax.tab.h"  // Bison 生成的头文件

void yyerror(const char *s);
%}

%option noyywrap

%%

[\t ]+                 { /* Ignore whitespace */ }
"\n"                   { return NEWLINE; }
"\\\n"                 { printf("> "); }
"|"                    { return PIPE; }
"&&"                   { return AND; }
"||"                   { return OR; }
\"(\\.|[^\"])*\"       { yylval.str = strdup(yytext); return STRING; }
[a-zA-Z0-9_\-\/.]+     { yylval.str = strdup(yytext); return WORD; }


%%

void yyerror(const char *s)
{
    fprintf(stderr, "error: %s\n", s);
}