-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathcomments.ll
More file actions
55 lines (40 loc) · 1.25 KB
/
comments.ll
File metadata and controls
55 lines (40 loc) · 1.25 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
%{
#pragma warning(disable: 4005)
#include <string>
#include "comments.yy.hpp"
#define YY_USER_ACTION loc.columns(yyleng);
#define YY_DECL yy_comments::parser::symbol_type yylex(yyscan_t yyscanner, yy_comments::location &loc)
#define MAKE(x) yy_comments::parser::make_ ## x(loc)
#define MAKE_VALUE(x, v) yy_comments::parser::make_ ## x((v), loc)
std::string comment;
%}
%option nounistd
%option yylineno
%option nounput
%option batch
%option never-interactive
%option reentrant
%option noyywrap
%option prefix="ll_comments"
%x COMMENT
%%
%{
// Code run each time yylex is called.
loc.step();
%}
#.*/\n ; // ignore comments
[ \t]+ loc.step();
\r loc.step();
\n {
loc.lines(yyleng);
loc.step();
}
\/\/.* ;
<INITIAL>"/*" { BEGIN(COMMENT); comment.clear(); }
<COMMENT>[^*\n]* |
<COMMENT>"*"+[^*/\n]* |
<COMMENT>\n comment += yytext;
<COMMENT>"*"+"/" { BEGIN(INITIAL); return MAKE_VALUE(STRING, comment);}
. { /*driver.error(loc, "invalid character");*/ return MAKE(ERROR_SYMBOL); }
<<EOF>> return MAKE(EOQ);
%%