struct name cleanup in preparation for AST + warning removal
[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.
18 */
19
8b9d5b5e 20#include <stdio.h>
34d3acc4 21#include "ctf-scanner.h"
8b9d5b5e
MD
22#include "ctf-parser.h"
23#include "ctf-ast.h"
24
609bd1bf
MD
25extern
26void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src);
27
28static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
29 __attribute__((unused));
30static int input (yyscan_t yyscanner) __attribute__((unused));
34d3acc4
MD
31
32#define printf_dbg(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, args)
33#define printf_dbg_noarg(fmt) fprintf(stderr, "%s: " fmt, __func__)
34
8b9d5b5e
MD
35%}
36
37%x comment_ml comment_sl string_lit char_const
34d3acc4
MD
38%option reentrant yylineno noyywrap bison-bridge
39%option extra-type="struct ctf_scanner *"
40 /* bison-locations */
8b9d5b5e
MD
41INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu)
42DIGIT [0-9]
43NONDIGIT [a-zA-Z_]
44HEXDIGIT [0-9A-Fa-f]
45OCTALDIGIT [0-7]
46UCHARLOWERCASE \\u{HEXDIGIT}{4}
47UCHARUPPERCASE \\U{HEXDIGIT}{8}
48ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE}
49IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})*
50ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+)
51%%
52
53 /*
54 * Using start conditions to deal with comments
55 * and strings.
56 */
57
58"/*" BEGIN(comment_ml);
59<comment_ml>[^*\n]* /* eat anything that's not a '*' */
60<comment_ml>"*"+[^*/\n]* /* eat up '*'s not followed by '/'s */
61<comment_ml>\n ++yylineno;
62<comment_ml>"*"+"/" BEGIN(INITIAL);
63
64"//" BEGIN(comment_sl);
65<comment_sl>[^\n]*\n ++yylineno; BEGIN(INITIAL);
66
67L\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
68\' BEGIN(char_const); return CHARACTER_CONSTANT_START;
69<char_const>\' BEGIN(INITIAL); return SQUOTE;
70
71L\" BEGIN(string_lit); return STRING_LITERAL_START;
72\" BEGIN(string_lit); return STRING_LITERAL_START;
73<string_lit>\" BEGIN(INITIAL); return DQUOTE;
74
75<char_const,string_lit>ESCSEQ return ESCSEQ;
76<char_const,string_lit>\n ; /* ignore */
77<char_const,string_lit>. return CHAR_STRING_TOKEN;
78
79"[" return LSBRAC;
80"]" return RSBRAC;
81"(" return LPAREN;
82")" return RPAREN;
83"{" return LBRAC;
84"}" return RBRAC;
85"->" return RARROW;
86"*" return STAR;
87"+" return PLUS;
88"-" return MINUS;
89"<" return LT;
90">" return GT;
91:= return TYPEASSIGN;
92: return COLON;
93; return SEMICOLON;
94"..." return DOTDOTDOT;
95"." return DOT;
96= return EQUAL;
97"," return COMMA;
98const return CONST;
99char return CHAR;
100double return DOUBLE;
101enum return ENUM;
102event return EVENT;
103floating_point return FLOATING_POINT;
104float return FLOAT;
105integer return INTEGER;
106int return INT;
107long return LONG;
108short return SHORT;
109signed return SIGNED;
110stream return STREAM;
111string return STRING;
112struct return STRUCT;
113trace return TRACE;
114typealias return TYPEALIAS;
115typedef return TYPEDEF;
116unsigned return UNSIGNED;
117variant return VARIANT;
118void return VOID;
119_Bool return _BOOL;
120_Complex return _COMPLEX;
121_Imaginary return _IMAGINARY;
122[1-9]{DIGIT}*{INTEGER_SUFFIX}? return DECIMAL_CONSTANT;
1230{OCTALDIGIT}*{INTEGER_SUFFIX}? return OCTAL_CONSTANT;
1240[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? return HEXADECIMAL_CONSTANT;
34d3acc4 125{IDENTIFIER} printf_dbg("<IDENTIFIER %s>\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER;
8b9d5b5e
MD
126[ \t\n]+ ; /* ignore */
127. return ERROR;
128%%
This page took 0.02733 seconds and 4 git commands to generate.