sink.text.pretty: abort on unknown field class type
[babeltrace.git] / src / plugins / ctf / common / metadata / lexer.lpp
CommitLineData
e98a2d6e
PP
1%{
2/*
0235b0db 3 * SPDX-License-Identifier: MIT
e98a2d6e 4 *
0235b0db 5 * Copyright 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
e98a2d6e 6 *
0235b0db 7 * Common Trace Formal Lexer
e98a2d6e
PP
8 */
9
c802cacb
SM
10#include <ctype.h>
11#include <stdio.h>
12
0746848c 13#define BT_LOG_OUTPUT_LEVEL ctf_plugin_metadata_log_level
f73367f8 14#define BT_LOG_TAG "PLUGIN-CTF-METADATA-LEXER"
6244258c 15#include "plugins/ctf/common/metadata/logging.hpp"
f73367f8 16
6244258c 17#include "plugins/ctf/common/metadata/ast.hpp"
c802cacb
SM
18#include "plugins/ctf/common/metadata/parser-wrap.hpp"
19#include "plugins/ctf/common/metadata/scanner.hpp"
e98a2d6e 20
f73367f8
PP
21#define YY_FATAL_ERROR(_msg) BT_LOGF_STR(_msg)
22
e98a2d6e
PP
23#define PARSE_INTEGER_LITERAL(base) \
24 do { \
25 errno = 0; \
26 yylval->ull = strtoull(yytext, NULL, base); \
27 if (errno) { \
50f6fce8 28 _BT_LOGE_APPEND_CAUSE_LINENO(yylineno, \
f73367f8
PP
29 "Cannot parser constant integer: " \
30 "base=%d, text=\"%s\"", base, yytext); \
31 return CTF_ERROR; \
e98a2d6e
PP
32 } \
33 } while (0)
e98a2d6e
PP
34%}
35
36%x comment_ml comment_sl string_lit char_const
37%option reentrant yylineno noyywrap bison-bridge
38%option extra-type="struct ctf_scanner *"
39 /* bison-locations */
40INTEGER_SUFFIX (U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
41DIGIT [0-9]
42NONDIGIT [a-zA-Z_]
43HEXDIGIT [0-9A-Fa-f]
44OCTALDIGIT [0-7]
45UCHARLOWERCASE \\u{HEXDIGIT}{4}
46UCHARUPPERCASE \\U{HEXDIGIT}{8}
47ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}
48IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
49%%
50
51 /*
52 * Using start conditions to deal with comments
53 * and strings.
f73367f8 54 */
e98a2d6e
PP
55
56"/*" BEGIN(comment_ml);
57<comment_ml>[^*\n]* /* eat anything that's not a '*' */
58<comment_ml>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
59<comment_ml>\n
60<comment_ml>"*"+"/" BEGIN(INITIAL);
61
62"//"[^\n]*\n /* skip comment */
63
d4c6eae5
MJ
64L?\"(\\.|[^\\"])*\" { if (import_string(yyextra, yylval, yytext, '\"') < 0) return CTF_ERROR; else return CTF_STRING_LITERAL; }
65L?\'(\\.|[^\\'])*\' { if (import_string(yyextra, yylval, yytext, '\'') < 0) return CTF_ERROR; else return CTF_CHARACTER_LITERAL; }
e98a2d6e 66
d4c6eae5
MJ
67"[" return CTF_LSBRAC;
68"]" return CTF_RSBRAC;
69"(" return CTF_LPAREN;
70")" return CTF_RPAREN;
71"{" return CTF_LBRAC;
72"}" return CTF_RBRAC;
73"->" return CTF_RARROW;
74"*" return CTF_STAR;
75"+" return CTF_PLUS;
76"-" return CTF_MINUS;
77"<" return CTF_LT;
78">" return CTF_GT;
79:= return CTF_TYPEASSIGN;
80: return CTF_COLON;
81; return CTF_SEMICOLON;
82"..." return CTF_DOTDOTDOT;
83"." return CTF_DOT;
84= return CTF_EQUAL;
85"," return CTF_COMMA;
86align setstring(yyextra, yylval, yytext); return CTF_TOK_ALIGN;
87const setstring(yyextra, yylval, yytext); return CTF_CONST;
88char setstring(yyextra, yylval, yytext); return CTF_CHAR;
89clock setstring(yyextra, yylval, yytext); return CTF_CLOCK;
90double setstring(yyextra, yylval, yytext); return CTF_DOUBLE;
91enum setstring(yyextra, yylval, yytext); return CTF_ENUM;
92env setstring(yyextra, yylval, yytext); return CTF_ENV;
93event setstring(yyextra, yylval, yytext); return CTF_EVENT;
94floating_point setstring(yyextra, yylval, yytext); return CTF_FLOATING_POINT;
95float setstring(yyextra, yylval, yytext); return CTF_FLOAT;
96integer setstring(yyextra, yylval, yytext); return CTF_INTEGER;
97int setstring(yyextra, yylval, yytext); return CTF_INT;
98long setstring(yyextra, yylval, yytext); return CTF_LONG;
99short setstring(yyextra, yylval, yytext); return CTF_SHORT;
100signed setstring(yyextra, yylval, yytext); return CTF_SIGNED;
101stream setstring(yyextra, yylval, yytext); return CTF_STREAM;
102string setstring(yyextra, yylval, yytext); return CTF_STRING;
103struct setstring(yyextra, yylval, yytext); return CTF_STRUCT;
104trace setstring(yyextra, yylval, yytext); return CTF_TRACE;
105callsite setstring(yyextra, yylval, yytext); return CTF_CALLSITE;
106typealias setstring(yyextra, yylval, yytext); return CTF_TYPEALIAS;
107typedef setstring(yyextra, yylval, yytext); return CTF_TYPEDEF;
108unsigned setstring(yyextra, yylval, yytext); return CTF_UNSIGNED;
109variant setstring(yyextra, yylval, yytext); return CTF_VARIANT;
110void setstring(yyextra, yylval, yytext); return CTF_VOID;
111_Bool setstring(yyextra, yylval, yytext); return CTF_BOOL;
112_Complex setstring(yyextra, yylval, yytext); return CTF_COMPLEX;
113_Imaginary setstring(yyextra, yylval, yytext); return CTF_IMAGINARY;
114[1-9]{DIGIT}*{INTEGER_SUFFIX}? PARSE_INTEGER_LITERAL(10); return CTF_INTEGER_LITERAL;
1150{OCTALDIGIT}*{INTEGER_SUFFIX}? PARSE_INTEGER_LITERAL(8); return CTF_INTEGER_LITERAL;
1160[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? PARSE_INTEGER_LITERAL(16); return CTF_INTEGER_LITERAL;
e98a2d6e 117
ef267d12 118{IDENTIFIER} BT_LOGT("Got identifier: id=\"%s\"", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
e98a2d6e 119[ \t\r\n] ; /* ignore */
50f6fce8 120. _BT_LOGE_APPEND_CAUSE_LINENO(yylineno, "Invalid character: char=\"%c\", val=0x%02x", isprint((unsigned char) yytext[0]) ? yytext[0] : '\0', yytext[0]); return CTF_ERROR;
e98a2d6e 121%%
This page took 0.140087 seconds and 4 git commands to generate.