-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathbazel.ll
More file actions
82 lines (62 loc) · 2.38 KB
/
bazel.ll
File metadata and controls
82 lines (62 loc) · 2.38 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
%{
#pragma warning(disable: 4005)
#include <string>
#include "bazel.yy.hpp"
#define YY_USER_ACTION loc.columns(yyleng);
#define YY_DECL yy_bazel::parser::symbol_type yylex(yyscan_t yyscanner, yy_bazel::location &loc)
#define MAKE(x) yy_bazel::parser::make_ ## x(loc)
#define MAKE_VALUE(x, v) yy_bazel::parser::make_ ## x((v), loc)
%}
%option nounistd
%option yylineno
%option nounput
%option batch
%option never-interactive
%option reentrant
%option noyywrap
%option prefix="ll_bazel"
identifier_old_no_integer [_a-zA-Z][_a-zA-Z0-9]*
identifier [_a-zA-Z0-9]+
quote1 "\'"[^'\\]*"\'"
quote2 "\""[^"\\]*"\""
%s IN_FUNCTION
%%
%{
// Code run each time yylex is called.
loc.step();
%}
#.*/\n // ignore comments
<IN_FUNCTION>\n\n {
loc.lines(yyleng);
loc.step();
BEGIN(0);
return MAKE(END_OF_DEF);
}
[ \t]+ loc.step();
\r loc.step();
\n {
loc.lines(yyleng);
loc.step();
}
";" return MAKE(SEMICOLON);
":" return MAKE(COLON);
"(" return MAKE(L_BRACKET);
")" return MAKE(R_BRACKET);
"{" return MAKE(L_CURLY_BRACKET);
"}" return MAKE(R_CURLY_BRACKET);
"[" return MAKE(L_SQUARE_BRACKET);
"]" return MAKE(R_SQUARE_BRACKET);
"," return MAKE(COMMA);
"\." return MAKE(POINT);
"\+" return MAKE(PLUS);
"->" return MAKE(R_ARROW);
"=" return MAKE(EQUAL);
"def" BEGIN(IN_FUNCTION); return MAKE(DEF);
and|elif|global|or|assert|else|if|except|pass|break|import|print|exec|in|raise|continue|finally|is|return|for|lambda|try|del|from|not|while return MAKE_VALUE(KEYWORD, yytext);
class return MAKE(CLASS);
{identifier} return MAKE_VALUE(ID, yytext);
{quote1} |
{quote2} return MAKE_VALUE(STRING, yytext);
. { /*driver.error(loc, "invalid character");*/ return MAKE(ERROR_SYMBOL); }
<<EOF>> return MAKE(EOQ);
%%