-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlexer.l
42 lines (35 loc) · 887 Bytes
/
lexer.l
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
%{
#include <string.h>
#include "y.tab.h"
#include "pipes.h"
#include "exec.h"
%}
%option nounput
%option noinput
%%
"XOR" return XOR;
"COPY" return COPY;
"VALUES" return VALUES;
"W"|"WRITE" return WRITE;
"R"|"RASTER" return RASTER;
"D"|"DISPLAY" return DISPLAY;
"PAGE" return PAGE;
"P"|"PIXEL" return PIXEL;
"L"|"LINE" return LINE;
"C"|"CLS" return CLEAR;
"I"|"INK" return INK;
"PAPER" return PAPER;
"B"|"BLIT" return BLIT;
"," return SEPARATOR;
[0-9]+ { yylval.integer=atoi(yytext); return NUMBER; }
%%
void exec_parse(char* command)
{
YY_BUFFER_STATE buffer = yy_scan_string(command);
yyparse();
yy_delete_buffer(buffer);
}
//void yyerror(char const *s) {
void yyerror (char const *msg) {
exec_error(msg, yylloc.last_line, yylloc.last_column);
}