Add missing permission notice in each source file
[babeltrace.git] / formats / ctf / metadata / ctf-lexer.l
1 %{
2 /*
3 * ctf-lexer.l
4 *
5 * Common Trace Formal Lexer
6 *
7 * Copyright 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a copy
10 * of this software and associated documentation files (the "Software"), to deal
11 * in the Software without restriction, including without limitation the rights
12 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 * copies of the Software, and to permit persons to whom the Software is
14 * furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 */
27
28 #include <stdio.h>
29 #include <babeltrace/babeltrace-internal.h>
30 #include "ctf-scanner.h"
31 #include "ctf-parser.h"
32 #include "ctf-ast.h"
33
34 __attribute__((visibility("hidden")))
35 void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src);
36
37 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
38 __attribute__((unused));
39 static int input (yyscan_t yyscanner) __attribute__((unused));
40
41 %}
42
43 %x comment_ml comment_sl string_lit char_const
44 %option reentrant yylineno noyywrap bison-bridge
45 %option extra-type="struct ctf_scanner *"
46 /* bison-locations */
47 INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
48 DIGIT [0-9]
49 NONDIGIT [a-zA-Z_]
50 HEXDIGIT [0-9A-Fa-f]
51 OCTALDIGIT [0-7]
52 UCHARLOWERCASE \\u{HEXDIGIT}{4}
53 UCHARUPPERCASE \\U{HEXDIGIT}{8}
54 ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}
55 IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
56 ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+)
57 %%
58
59 /*
60 * Using start conditions to deal with comments
61 * and strings.
62 */
63
64 "/*" BEGIN(comment_ml);
65 <comment_ml>[^*\n]* /* eat anything that's not a '*' */
66 <comment_ml>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
67 <comment_ml>\n ++yylineno;
68 <comment_ml>"*"+"/" BEGIN(INITIAL);
69
70 "//" BEGIN(comment_sl);
71 <comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
72
73 L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
74 \' BEGIN(char_const); return CHARACTER_CONSTANT_START;
75 <char_const>\' BEGIN(INITIAL); return SQUOTE;
76
77 L\" BEGIN(string_lit); return STRING_LITERAL_START;
78 \" BEGIN(string_lit); return STRING_LITERAL_START;
79 <string_lit>\" BEGIN(INITIAL); return DQUOTE;
80
81 <char_const,string_lit>ESCSEQ return ESCSEQ;
82 <char_const,string_lit>\n ; /* ignore */
83 <char_const,string_lit>. setstring(yyextra, yylval, yytext); return CHAR_STRING_TOKEN;
84
85 "[" return LSBRAC;
86 "]" return RSBRAC;
87 "(" return LPAREN;
88 ")" return RPAREN;
89 "{" return LBRAC;
90 "}" return RBRAC;
91 "->" return RARROW;
92 "*" return STAR;
93 "+" return PLUS;
94 "-" return MINUS;
95 "<" return LT;
96 ">" return GT;
97 := return TYPEASSIGN;
98 : return COLON;
99 ; return SEMICOLON;
100 "..." return DOTDOTDOT;
101 "." return DOT;
102 = return EQUAL;
103 "," return COMMA;
104 align setstring(yyextra, yylval, yytext); return TOK_ALIGN;
105 const setstring(yyextra, yylval, yytext); return CONST;
106 char setstring(yyextra, yylval, yytext); return CHAR;
107 clock setstring(yyextra, yylval, yytext); return CLOCK;
108 double setstring(yyextra, yylval, yytext); return DOUBLE;
109 enum setstring(yyextra, yylval, yytext); return ENUM;
110 env setstring(yyextra, yylval, yytext); return ENV;
111 event setstring(yyextra, yylval, yytext); return EVENT;
112 floating_point setstring(yyextra, yylval, yytext); return FLOATING_POINT;
113 float setstring(yyextra, yylval, yytext); return FLOAT;
114 integer setstring(yyextra, yylval, yytext); return INTEGER;
115 int setstring(yyextra, yylval, yytext); return INT;
116 long setstring(yyextra, yylval, yytext); return LONG;
117 short setstring(yyextra, yylval, yytext); return SHORT;
118 signed setstring(yyextra, yylval, yytext); return SIGNED;
119 stream setstring(yyextra, yylval, yytext); return STREAM;
120 string setstring(yyextra, yylval, yytext); return STRING;
121 struct setstring(yyextra, yylval, yytext); return STRUCT;
122 trace setstring(yyextra, yylval, yytext); return TRACE;
123 callsite setstring(yyextra, yylval, yytext); return CALLSITE;
124 typealias setstring(yyextra, yylval, yytext); return TYPEALIAS;
125 typedef setstring(yyextra, yylval, yytext); return TYPEDEF;
126 unsigned setstring(yyextra, yylval, yytext); return UNSIGNED;
127 variant setstring(yyextra, yylval, yytext); return VARIANT;
128 void setstring(yyextra, yylval, yytext); return VOID;
129 _Bool setstring(yyextra, yylval, yytext); return _BOOL;
130 _Complex setstring(yyextra, yylval, yytext); return _COMPLEX;
131 _Imaginary setstring(yyextra, yylval, yytext); return _IMAGINARY;
132 [1-9]{DIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return DECIMAL_CONSTANT;
133 0{OCTALDIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
134 0[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
135 {IDENTIFIER} printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
136 [ \t\n]+ ; /* ignore */
137 . return ERROR;
138 %%
This page took 0.046307 seconds and 4 git commands to generate.