aboutsummaryrefslogtreecommitdiffstats
path: root/lex.l
blob: c530ca0ffd1154d5d6352c18ea52a5fe312ef7f9 (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
%{
#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; }
\"(\\.|[^\"])*\"       { 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);
}