Add missing permission notice in each source file
[babeltrace.git] / formats / ctf / metadata / ctf-lexer.l
CommitLineData
8b9d5b5e 1%{
c59a87f5
MD
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.
c462e188
MD
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.
c59a87f5
MD
26 */
27
8b9d5b5e 28#include <stdio.h>
70bd0a12 29#include <babeltrace/babeltrace-internal.h>
34d3acc4 30#include "ctf-scanner.h"
8b9d5b5e
MD
31#include "ctf-parser.h"
32#include "ctf-ast.h"
33
09349576 34__attribute__((visibility("hidden")))
609bd1bf
MD
35void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src);
36
37static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
38 __attribute__((unused));
39static int input (yyscan_t yyscanner) __attribute__((unused));
34d3acc4 40
8b9d5b5e
MD
41%}
42
43%x comment_ml comment_sl string_lit char_const
34d3acc4
MD
44%option reentrant yylineno noyywrap bison-bridge
45%option extra-type="struct ctf_scanner *"
46 /* bison-locations */
8b9d5b5e
MD
47INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
48DIGIT [0-9]
49NONDIGIT [a-zA-Z_]
50HEXDIGIT [0-9A-Fa-f]
51OCTALDIGIT [0-7]
52UCHARLOWERCASE \\u{HEXDIGIT}{4}
53UCHARUPPERCASE \\U{HEXDIGIT}{8}
54ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}
55IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
56ESCSEQ \\(\'|\"|\?|\\|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
73L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
74\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
75<char_const>\' BEGIN(INITIAL); return SQUOTE;
76
77L\" 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 */
6dc474b8 83<char_const,string_lit>. setstring(yyextra, yylval, yytext); return CHAR_STRING_TOKEN;
8b9d5b5e
MD
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;
b7e35bad 104align setstring(yyextra, yylval, yytext); return TOK_ALIGN;
6dc474b8
MD
105const setstring(yyextra, yylval, yytext); return CONST;
106char setstring(yyextra, yylval, yytext); return CHAR;
73d15916 107clock setstring(yyextra, yylval, yytext); return CLOCK;
6dc474b8
MD
108double setstring(yyextra, yylval, yytext); return DOUBLE;
109enum setstring(yyextra, yylval, yytext); return ENUM;
e2c76a4d 110env setstring(yyextra, yylval, yytext); return ENV;
6dc474b8
MD
111event setstring(yyextra, yylval, yytext); return EVENT;
112floating_point setstring(yyextra, yylval, yytext); return FLOATING_POINT;
113float setstring(yyextra, yylval, yytext); return FLOAT;
114integer setstring(yyextra, yylval, yytext); return INTEGER;
115int setstring(yyextra, yylval, yytext); return INT;
116long setstring(yyextra, yylval, yytext); return LONG;
117short setstring(yyextra, yylval, yytext); return SHORT;
118signed setstring(yyextra, yylval, yytext); return SIGNED;
119stream setstring(yyextra, yylval, yytext); return STREAM;
120string setstring(yyextra, yylval, yytext); return STRING;
121struct setstring(yyextra, yylval, yytext); return STRUCT;
122trace setstring(yyextra, yylval, yytext); return TRACE;
f133896d 123callsite setstring(yyextra, yylval, yytext); return CALLSITE;
6dc474b8
MD
124typealias setstring(yyextra, yylval, yytext); return TYPEALIAS;
125typedef setstring(yyextra, yylval, yytext); return TYPEDEF;
126unsigned setstring(yyextra, yylval, yytext); return UNSIGNED;
127variant setstring(yyextra, yylval, yytext); return VARIANT;
128void 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;
1330{OCTALDIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT;
1340[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT;
6743f229 135{IDENTIFIER} printf_debug("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
8b9d5b5e
MD
136[ \t\n]+ ; /* ignore */
137. return ERROR;
138%%
This page took 0.047641 seconds and 4 git commands to generate.