X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=formats%2Fctf%2Fmetadata%2Fctf-lexer.l;h=a282bf7a473d6a8bd04ab3feba5906e801a7a213;hp=7a0e73fe1abb7c8e73690fe64f645c4242f25227;hb=d876a5baf224612e7e44d3cfda2dc1d57ea91ea4;hpb=70bd0a12b09ce7f233189cf07e090fda593ebc48 diff --git a/formats/ctf/metadata/ctf-lexer.l b/formats/ctf/metadata/ctf-lexer.l index 7a0e73fe..a282bf7a 100644 --- a/formats/ctf/metadata/ctf-lexer.l +++ b/formats/ctf/metadata/ctf-lexer.l @@ -15,6 +15,14 @@ * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. */ #include @@ -23,13 +31,16 @@ #include "ctf-parser.h" #include "ctf-ast.h" -extern +BT_HIDDEN 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)); +BT_HIDDEN +int import_string(struct ctf_scanner *scanner, YYSTYPE *lvalp, const char *src, char delim); + %} %x comment_ml comment_sl string_lit char_const @@ -45,7 +56,6 @@ UCHARLOWERCASE \\u{HEXDIGIT}{4} UCHARUPPERCASE \\U{HEXDIGIT}{8} ID_NONDIGIT {NONDIGIT}|{UCHARLOWERCASE}|{UCHARUPPERCASE} IDENTIFIER {ID_NONDIGIT}({ID_NONDIGIT}|{DIGIT})* -ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIGIT}{8}|x{HEXDIGIT}+) %% /* @@ -56,23 +66,14 @@ ESCSEQ \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIG "/*" BEGIN(comment_ml); [^*\n]* /* eat anything that's not a '*' */ "*"+[^*/\n]* /* eat up '*'s not followed by '/'s */ -\n ++yylineno; +\n "*"+"/" BEGIN(INITIAL); "//" BEGIN(comment_sl); -[^\n]*\n ++yylineno; BEGIN(INITIAL); - -L\' BEGIN(char_const); return CHARACTER_CONSTANT_START; -\' BEGIN(char_const); return CHARACTER_CONSTANT_START; -\' BEGIN(INITIAL); return SQUOTE; - -L\" BEGIN(string_lit); return STRING_LITERAL_START; -\" BEGIN(string_lit); return STRING_LITERAL_START; -\" BEGIN(INITIAL); return DQUOTE; +[^\n]*\n BEGIN(INITIAL); -ESCSEQ return ESCSEQ; -\n ; /* ignore */ -. setstring(yyextra, yylval, yytext); return CHAR_STRING_TOKEN; +L?\"(\\.|[^\\"])*\" { if (import_string(yyextra, yylval, yytext, '\"') < 0) return ERROR; else return STRING_LITERAL; } +L?\'(\\.|[^\\'])*\' { if (import_string(yyextra, yylval, yytext, '\'') < 0) return ERROR; else return CHARACTER_LITERAL; } "[" return LSBRAC; "]" return RSBRAC; @@ -96,8 +97,10 @@ L\" BEGIN(string_lit); return STRING_LITERAL_START; align setstring(yyextra, yylval, yytext); return TOK_ALIGN; const setstring(yyextra, yylval, yytext); return CONST; char setstring(yyextra, yylval, yytext); return CHAR; +clock setstring(yyextra, yylval, yytext); return CLOCK; double setstring(yyextra, yylval, yytext); return DOUBLE; enum setstring(yyextra, yylval, yytext); return ENUM; +env setstring(yyextra, yylval, yytext); return ENV; event setstring(yyextra, yylval, yytext); return EVENT; floating_point setstring(yyextra, yylval, yytext); return FLOATING_POINT; float setstring(yyextra, yylval, yytext); return FLOAT; @@ -110,6 +113,7 @@ stream setstring(yyextra, yylval, yytext); return STREAM; string setstring(yyextra, yylval, yytext); return STRING; struct setstring(yyextra, yylval, yytext); return STRUCT; trace setstring(yyextra, yylval, yytext); return TRACE; +callsite setstring(yyextra, yylval, yytext); return CALLSITE; typealias setstring(yyextra, yylval, yytext); return TYPEALIAS; typedef setstring(yyextra, yylval, yytext); return TYPEDEF; unsigned setstring(yyextra, yylval, yytext); return UNSIGNED; @@ -122,6 +126,6 @@ _Imaginary setstring(yyextra, yylval, yytext); return _IMAGINARY; 0{OCTALDIGIT}*{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return OCTAL_CONSTANT; 0[xX]{HEXDIGIT}+{INTEGER_SUFFIX}? setstring(yyextra, yylval, yytext); return HEXADECIMAL_CONSTANT; {IDENTIFIER} printf_debug("\n", yytext); setstring(yyextra, yylval, yytext); if (is_type(yyextra, yytext)) return ID_TYPE; else return IDENTIFIER; -[ \t\n]+ ; /* ignore */ -. return ERROR; +[ \t\r\n] ; /* ignore */ +. printfl_error(yylineno, "invalid character '0x%02X'", yytext[0]); return ERROR; %%