X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-lexer.l;h=56122813c91766d51d61a4d20109f29ab9f20a7d;hp=763a1bb8d7c99974f6aab0c0c35abd7cd36a339d;hb=8e1a0b6f7073b720e7fbf201b571c0d093b78788;hpb=8b9d5b5e700bdf66edf4c0fa035fdf10cb3b36f3 diff --git a/formats/ctf/metadata/ctf-lexer.l b/formats/ctf/metadata/ctf-lexer.l index 763a1bb8..56122813 100644 --- a/formats/ctf/metadata/ctf-lexer.l +++ b/formats/ctf/metadata/ctf-lexer.l @@ -1,13 +1,42 @@ %{ +/* + * ctf-lexer.l + * + * Common Trace Formal Lexer + * + * Copyright 2010 - Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + #include +#include "ctf-scanner.h" #include "ctf-parser.h" #include "ctf-ast.h" -extern YYSTYPE yylval; -extern void setstring(const char *src); +extern +void setstring(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src); + +static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner) + __attribute__((unused)); +static int input (yyscan_t yyscanner) __attribute__((unused)); + +#define printf_dbg(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, ##args) + %} %x comment_ml comment_sl string_lit char_const +%option reentrant yylineno noyywrap bison-bridge +%option extra-type="struct ctf_scanner *" + /* bison-locations */ INTEGER_SUFFIX [ \n\t]*(U|UL|ULL|LU|LLU|Ul|Ull|lU|llU|u|uL|uLL|Lu|LLu|ul|ull|lu|llu) DIGIT [0-9] NONDIGIT [a-zA-Z_] @@ -92,7 +121,7 @@ _Imaginary return _IMAGINARY; [1-9]{DIGIT}*{INTEGER_SUFFIX}? return DECIMAL_CONSTANT; 0{OCTALDIGIT}*{INTEGER_SUFFIX}? return OCTAL_CONSTANT; 0[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? return HEXADECIMAL_CONSTANT; -{IDENTIFIER} fprintf(stderr, "\n", yytext); setstring(yytext); if (is_type(yytext)) return ID_TYPE; else return IDENTIFIER; +{IDENTIFIER} printf_dbg("\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER; [ \t\n]+ ; /* ignore */ . return ERROR; %%