blob: 1d0b9f2346393913a0879c7a9df84f7a4e002963 (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
|
%{
#include <stdarg.h>
#include <stdio.h>
#include <stdint.h> // for intptr_t
#include <gmp.h>
#include "pbc_utils.h"
#include "pbc_field.h"
#include "pbc_tree.h"
#define YYSTYPE tree_ptr
#include "parser.tab.h"
extern int option_easy;
%}
%option nounput noinput
%x COMMENT
%%
\/\* BEGIN(COMMENT); // Open C-style comment.
<COMMENT>\*\/ BEGIN(0); // Close C-style comment.
<COMMENT>. // Within a C-style comment.
<COMMENT>\n // Within a C-style comment.
#.*$ // Comment.
[ \t\r]* // Whitespace.
define return DEFINE;
[0-9]+ yylval = tree_new_z(yytext); return NUM;
[a-zA-Z_][a-zA-Z0-9_]* yylval = tree_new_id(yytext); return ID;
:= return ASSIGN;
== return EQ;
!= return NE;
\< return LT;
\> return T_GT;
\<= return LE;
\>= return GE;
\+ return PLUS;
- return MINUS;
\/ return DIVIDE;
\* return TIMES;
\^ return POW;
; return TERMINATOR;
\, return COMMA;
\? return QUESTION;
: return COLON;
\( return LPAR;
\) return RPAR;
\[ return LSQU;
\] return RSQU;
\{ return LBRACE;
\} return RBRACE;
\n if (option_easy) return TERMINATOR;
= return option_easy ? ASSIGN : UNKNOWN;
. return UNKNOWN;
%%
|