aboutsummaryrefslogtreecommitdiff
path: root/src/lexer.l
blob: 74d301a4f32b5167851c3e105965564b7f7d7c99 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
%option noinput
%option nounput
%option noyywrap
%option yylineno

%{
#include <err.h>
#include <stdlib.h>

#include "parser.h"
#include "pinocchio.h"

#define YY_USER_ACTION yylloc.first_line = yylloc.last_line = yylineno;

extern const char *current_file;
%}

%%

¬|!    { return NOT;   }
∧|&&   { return AND;   }
∨|\|\| { return OR;    }
⊻|⊕|~  { return XOR;   }
⇒|=>   { return IMPL;  }
\<=>|⇔ { return EQUIV; }
\(     { return OPAR;  }
\)     { return CPAR;  }
\|     { return '|';   }
\\     { return '\\';  }
\n     { return EOL;   }

[a-zA-Z] {
	yylval.ch = *yytext;
	return IDENT;
}

[ \t]+ ;

. {
	user_error("%s:%d: Unrecognized character ‘%c’",
		current_file, yylineno, *yytext);
}

%%