agent_lexer.ll 19.9 KB
Newer Older
1 2 3 4 5 6 7
/* Copyright (C) 2017 Internet Systems Consortium, Inc. ("ISC")

   This Source Code Form is subject to the terms of the Mozilla Public
   License, v. 2.0. If a copy of the MPL was not distributed with this
   file, You can obtain one at http://mozilla.org/MPL/2.0/. */

%{ /* -*- C++ -*- */
8 9 10 11

/* Generated files do not make clang static analyser so happy */
#ifndef __clang_analyzer__

12 13 14 15 16 17 18 19 20 21
#include <cerrno>
#include <climits>
#include <cstdlib>
#include <string>
#include <agent/parser_context.h>
#include <asiolink/io_address.h>
#include <boost/lexical_cast.hpp>
#include <exceptions/exceptions.h>
#include <cc/dhcp_config_error.h>

22 23 24 25 26 27
/* Please avoid C++ style comments (// ... eol) as they break flex 2.6.2 */

/* Work around an incompatibility in flex (at least versions
   2.5.31 through 2.5.33): it generates code that does
   not conform to C89.  See Debian bug 333231
   <http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=333231>. */
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
# undef yywrap
# define yywrap() 1

namespace {

bool start_token_flag = false;

isc::agent::ParserContext::ParserType start_token_value;
unsigned int comment_start_line = 0;

using namespace isc;
using isc::agent::AgentParser;

};

43
/* To avoid the call to exit... oops! */
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
#define YY_FATAL_ERROR(msg) isc::agent::ParserContext::fatal(msg)
%}

/* noyywrap disables automatic rewinding for the next file to parse. Since we
   always parse only a single string, there's no need to do any wraps. And
   using yywrap requires linking with -lfl, which provides the default yywrap
   implementation that always returns 1 anyway. */
%option noyywrap

/* nounput simplifies the lexer, by removing support for putting a character
   back into the input stream. We never use such capability anyway. */
%option nounput

/* batch means that we'll never use the generated lexer interactively. */
%option batch

/* avoid to get static global variables to remain with C++. */
/* in last resort %option reentrant */

/* Enables debug mode. To see the debug messages, one needs to also set
   yy_flex_debug to 1, then the debug messages will be printed on stderr. */
%option debug

/* I have no idea what this option does, except it was specified in the bison
   examples and Postgres folks added it to remove gcc 4.3 warnings. Let's
   be on the safe side and keep it. */
%option noinput

%x COMMENT
%x DIR_ENTER DIR_INCLUDE DIR_EXIT

/* These are not token expressions yet, just convenience expressions that
   can be used during actual token definitions. Note some can match
   incorrect inputs (e.g., IP addresses) which must be checked. */
int   \-?[0-9]+
blank [ \t\r]

UnicodeEscapeSequence           u[0-9A-Fa-f]{4}
JSONEscapeCharacter             ["\\/bfnrt]
JSONEscapeSequence              {JSONEscapeCharacter}|{UnicodeEscapeSequence}
JSONStandardCharacter           [^\x00-\x1f"\\]
JSONStringCharacter             {JSONStandardCharacter}|\\{JSONEscapeSequence}
JSONString                      \"{JSONStringCharacter}*\"

/* for errors */

BadUnicodeEscapeSequence        u[0-9A-Fa-f]{0,3}[^0-9A-Fa-f]
BadJSONEscapeSequence           [^"\\/bfnrtu]|{BadUnicodeEscapeSequence}
ControlCharacter                [\x00-\x1f]
ControlCharacterFill            [^"\\]|\\{JSONEscapeSequence}

%{
96 97 98
/* This code run each time a pattern is matched. It updates the location
   by moving it ahead by yyleng bytes. yyleng specifies the length of the
   currently matched token. */
99 100 101 102 103 104
#define YY_USER_ACTION  driver.loc_.columns(yyleng);
%}

%%

%{
105 106 107
    /* This part of the code is copied over to the verbatim to the top
       of the generated yylex function. Explanation:
       http://www.gnu.org/software/bison/manual/html_node/Multiple-start_002dsymbols.html */
108

109
    /* Code run each time yylex is called. */
110 111
    driver.loc_.step();

112 113 114 115 116 117
    /* We currently have 3 points of entries defined:
       START_JSON - which expects any valid JSON
       START_AGENT - which expects full configuration (with outer map and Control-agent
                     object in it.
       START_SUB_AGENT - which expects only content of the Control-agent, this is
                         primarily useful for testing. */
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
    if (start_token_flag) {
        start_token_flag = false;
        switch (start_token_value) {
        case ParserContext::PARSER_JSON:
        default:
            return isc::agent::AgentParser::make_START_JSON(driver.loc_);
        case ParserContext::PARSER_AGENT:
            return isc::agent::AgentParser::make_START_AGENT(driver.loc_);
        case ParserContext::PARSER_SUB_AGENT:
            return isc::agent::AgentParser::make_START_SUB_AGENT(driver.loc_);
        }
    }
%}

#.* ;

"//"(.*) ;

"/*" {
  BEGIN(COMMENT);
  comment_start_line = driver.loc_.end.line;;
}

<COMMENT>"*/" BEGIN(INITIAL);
<COMMENT>. ;
<COMMENT><<EOF>> {
    isc_throw(ParseError, "Comment not closed. (/* in line " << comment_start_line);
}

"<?" BEGIN(DIR_ENTER);
<DIR_ENTER>"include" BEGIN(DIR_INCLUDE);
<DIR_INCLUDE>\"([^\"\n])+\" {
150
    /* Include directive. */
151

152
    /* Extract the filename. */
153 154 155 156 157 158 159 160 161 162 163 164
    std::string tmp(yytext+1);
    tmp.resize(tmp.size() - 1);

    driver.includeFile(tmp);
}
<DIR_ENTER,DIR_INCLUDE,DIR_EXIT><<EOF>> {
    isc_throw(ParseError, "Directive not closed.");
}
<DIR_EXIT>"?>" BEGIN(INITIAL);


<*>{blank}+   {
165
    /* Ok, we found a with space. Let's ignore it and update loc variable. */
166 167 168 169
    driver.loc_.step();
}

<*>[\n]+      {
170
    /* Newline found. Let's update the location and continue. */
171 172 173 174 175 176
    driver.loc_.lines(yyleng);
    driver.loc_.step();
}


\"Control-agent\" {
177 178
    switch(driver.ctx_) {
    case ParserContext::CONFIG:
179
        return AgentParser::make_CONTROL_AGENT(driver.loc_);
180
    default:
181 182 183 184 185
        return AgentParser::make_STRING("Control-agent", driver.loc_);
    }
}

\"http-host\" {
186 187
    switch(driver.ctx_) {
    case ParserContext::AGENT:
188
        return AgentParser::make_HTTP_HOST(driver.loc_);
189
    default:
190 191 192 193 194
        return AgentParser::make_STRING("http-host", driver.loc_);
    }
}

\"http-port\" {
195 196
    switch(driver.ctx_) {
    case ParserContext::AGENT:
197
        return AgentParser::make_HTTP_PORT(driver.loc_);
198
    default:
199 200 201 202
        return AgentParser::make_STRING("http-port", driver.loc_);
    }
}

203 204 205 206 207 208 209 210 211
\"control-sockets\" {
    switch(driver.ctx_) {
    case ParserContext::AGENT:
        return AgentParser::make_CONTROL_SOCKETS(driver.loc_);
    default:
        return AgentParser::make_STRING("control-sockets", driver.loc_);
    }
}

212
\"dhcp4\" {
213 214
    switch(driver.ctx_) {
    case ParserContext::CONTROL_SOCKETS:
215
        return AgentParser::make_DHCP4_SERVER(driver.loc_);
216
    default:
217
        return AgentParser::make_STRING("dhcp4", driver.loc_);
218 219 220
    }
}

221
\"dhcp6\" {
222 223
    switch(driver.ctx_) {
    case ParserContext::CONTROL_SOCKETS:
224
        return AgentParser::make_DHCP6_SERVER(driver.loc_);
225
    default:
226
        return AgentParser::make_STRING("dhcp6", driver.loc_);
227 228 229
    }
}

230
\"d2\" {
231 232
    switch(driver.ctx_) {
    case ParserContext::CONTROL_SOCKETS:
233
        return AgentParser::make_D2_SERVER(driver.loc_);
234
    default:
235
        return AgentParser::make_STRING("d2", driver.loc_);
236 237 238
    }
}

239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
\"socket-name\" {
    switch(driver.ctx_) {
    case ParserContext::SERVER:
        return AgentParser::make_SOCKET_NAME(driver.loc_);
    default:
        return AgentParser::make_STRING("socket-name", driver.loc_);
    }
}

\"socket-type\" {
    switch(driver.ctx_) {
    case ParserContext::SERVER:
        return AgentParser::make_SOCKET_TYPE(driver.loc_);
    default:
        return AgentParser::make_STRING("socket-type", driver.loc_);
    }
}

\"unix\" {
    switch(driver.ctx_) {
    case ParserContext::SOCKET_TYPE:
260
        return AgentParser::make_UNIX(driver.loc_);
261 262
    default:
        return AgentParser::make_STRING("unix", driver.loc_);
263 264 265
    }
}

266 267 268 269 270 271
\"hooks-libraries\" {
    switch(driver.ctx_) {
    case ParserContext::AGENT:
        return AgentParser::make_HOOKS_LIBRARIES(driver.loc_);
    default:
        return AgentParser::make_STRING("hooks-libraries", driver.loc_);
272 273 274
    }
}

275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291
\"library\" {
    switch(driver.ctx_) {
    case ParserContext::HOOKS_LIBRARIES:
        return AgentParser::make_LIBRARY(driver.loc_);
    default:
        return AgentParser::make_STRING("library", driver.loc_);
    }
}

\"parameters\" {
    switch(driver.ctx_) {
    case ParserContext::HOOKS_LIBRARIES:
        return AgentParser::make_PARAMETERS(driver.loc_);
    default:
        return AgentParser::make_STRING("parameters", driver.loc_);
    }
}
292 293

\"Logging\" {
294 295
    switch(driver.ctx_) {
    case ParserContext::CONFIG:
296
        return AgentParser::make_LOGGING(driver.loc_);
297
    default:
298 299 300 301 302
        return AgentParser::make_STRING("Logging", driver.loc_);
    }
}

\"loggers\" {
303 304
    switch(driver.ctx_) {
    case ParserContext::LOGGING:
305
        return AgentParser::make_LOGGERS(driver.loc_);
306
    default:
307 308 309 310
        return AgentParser::make_STRING("loggers", driver.loc_);
    }
}

311 312 313 314 315 316 317 318 319
\"name\" {
    switch(driver.ctx_) {
    case ParserContext::LOGGERS:
        return AgentParser::make_NAME(driver.loc_);
    default:
        return AgentParser::make_STRING("name", driver.loc_);
    }
}

320
\"output_options\" {
321 322
    switch(driver.ctx_) {
    case ParserContext::LOGGERS:
323
        return AgentParser::make_OUTPUT_OPTIONS(driver.loc_);
324
    default:
325 326 327 328 329
        return AgentParser::make_STRING("output_options", driver.loc_);
    }
}

\"output\" {
330 331
    switch(driver.ctx_) {
    case ParserContext::OUTPUT_OPTIONS:
332
        return AgentParser::make_OUTPUT(driver.loc_);
333
    default:
334 335 336 337
        return AgentParser::make_STRING("output", driver.loc_);
    }
}

338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
\"flush\" {
    switch(driver.ctx_) {
    case ParserContext::OUTPUT_OPTIONS:
        return AgentParser::make_FLUSH(driver.loc_);
    default:
        return AgentParser::make_STRING("flush", driver.loc_);
    }
}

\"maxsize\" {
    switch(driver.ctx_) {
    case ParserContext::OUTPUT_OPTIONS:
        return AgentParser::make_MAXSIZE(driver.loc_);
    default:
        return AgentParser::make_STRING("maxsize", driver.loc_);
    }
}

\"maxver\" {
    switch(driver.ctx_) {
    case ParserContext::OUTPUT_OPTIONS:
        return AgentParser::make_MAXVER(driver.loc_);
    default:
        return AgentParser::make_STRING("maxver", driver.loc_);
    }
}

365
\"debuglevel\" {
366 367
    switch(driver.ctx_) {
    case ParserContext::LOGGERS:
368
        return AgentParser::make_DEBUGLEVEL(driver.loc_);
369
    default:
370 371 372 373 374
        return AgentParser::make_STRING("debuglevel", driver.loc_);
    }
}

\"severity\" {
375 376
    switch(driver.ctx_) {
    case ParserContext::LOGGERS:
377
        return AgentParser::make_SEVERITY(driver.loc_);
378
    default:
379 380 381 382 383
        return AgentParser::make_STRING("severity", driver.loc_);
    }
}

\"Dhcp4\" {
384 385
    switch(driver.ctx_) {
    case ParserContext::CONFIG:
386
        return AgentParser::make_DHCP4(driver.loc_);
387
    default:
388 389 390 391 392
        return AgentParser::make_STRING("Dhcp4", driver.loc_);
    }
}

\"Dhcp6\" {
393 394 395 396 397 398 399 400 401 402 403 404 405 406
    switch(driver.ctx_) {
    case ParserContext::CONFIG:
        return AgentParser::make_DHCP6(driver.loc_);
    default:
        return AgentParser::make_STRING("Dhcp6", driver.loc_);
    }
}

\"DhcpDdns\" {
    switch(driver.ctx_) {
    case ParserContext::CONFIG:
        return AgentParser::make_DHCPDDNS(driver.loc_);
    default:
        return AgentParser::make_STRING("DhcpDdns", driver.loc_);
407 408 409 410
    }
}

{JSONString} {
411 412 413
    /* A string has been matched. It contains the actual string and single quotes.
       We need to get those quotes out of the way and just use its content, e.g.
       for 'foo' we should get foo */
414 415 416 417 418 419 420 421 422 423
    std::string raw(yytext+1);
    size_t len = raw.size() - 1;
    raw.resize(len);
    std::string decoded;
    decoded.reserve(len);
    for (size_t pos = 0; pos < len; ++pos) {
        int b = 0;
        char c = raw[pos];
        switch (c) {
        case '"':
424
            /* impossible condition */
425
            driver.error(driver.loc_, "Bad quote in \"" + raw + "\"");
426
            break;
427 428 429
        case '\\':
            ++pos;
            if (pos >= len) {
430
                /* impossible condition */
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
                driver.error(driver.loc_, "Overflow escape in \"" + raw + "\"");
            }
            c = raw[pos];
            switch (c) {
            case '"':
            case '\\':
            case '/':
                decoded.push_back(c);
                break;
            case 'b':
                decoded.push_back('\b');
                break;
            case 'f':
                decoded.push_back('\f');
                break;
            case 'n':
                decoded.push_back('\n');
                break;
            case 'r':
                decoded.push_back('\r');
                break;
            case 't':
                decoded.push_back('\t');
                break;
            case 'u':
456
                /* support only \u0000 to \u00ff */
457 458
                ++pos;
                if (pos + 4 > len) {
459
                    /* impossible condition */
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
                    driver.error(driver.loc_,
                                 "Overflow unicode escape in \"" + raw + "\"");
                }
                if ((raw[pos] != '0') || (raw[pos + 1] != '0')) {
                    driver.error(driver.loc_, "Unsupported unicode escape in \"" + raw + "\"");
                }
                pos += 2;
                c = raw[pos];
                if ((c >= '0') && (c <= '9')) {
                    b = (c - '0') << 4;
                } else if ((c >= 'A') && (c <= 'F')) {
                    b = (c - 'A' + 10) << 4;
                } else if ((c >= 'a') && (c <= 'f')) {
                    b = (c - 'a' + 10) << 4;
                } else {
475
                    /* impossible condition */
476 477 478 479 480 481 482 483 484 485 486
                    driver.error(driver.loc_, "Not hexadecimal in unicode escape in \"" + raw + "\"");
                }
                pos++;
                c = raw[pos];
                if ((c >= '0') && (c <= '9')) {
                    b |= c - '0';
                } else if ((c >= 'A') && (c <= 'F')) {
                    b |= c - 'A' + 10;
                } else if ((c >= 'a') && (c <= 'f')) {
                    b |= c - 'a' + 10;
                } else {
487
                    /* impossible condition */
488 489 490 491 492
                    driver.error(driver.loc_, "Not hexadecimal in unicode escape in \"" + raw + "\"");
                }
                decoded.push_back(static_cast<char>(b & 0xff));
                break;
            default:
493
                /* impossible condition */
494 495 496 497 498
                driver.error(driver.loc_, "Bad escape in \"" + raw + "\"");
            }
            break;
        default:
            if ((c >= 0) && (c < 0x20)) {
499
                /* impossible condition */
500 501 502 503 504 505 506 507 508 509
                driver.error(driver.loc_, "Invalid control in \"" + raw + "\"");
            }
            decoded.push_back(c);
        }
    }

    return AgentParser::make_STRING(decoded, driver.loc_);
}

\"{JSONStringCharacter}*{ControlCharacter}{ControlCharacterFill}*\" {
510
    /* Bad string with a forbidden control character inside */
511 512 513 514
    driver.error(driver.loc_, "Invalid control in " + std::string(yytext));
}

\"{JSONStringCharacter}*\\{BadJSONEscapeSequence}[^\x00-\x1f"]*\" {
515
    /* Bad string with a bad escape inside */
516 517 518 519
    driver.error(driver.loc_, "Bad escape in " + std::string(yytext));
}

\"{JSONStringCharacter}*\\\" {
520
    /* Bad string with an open escape at the end */
521 522 523 524 525 526 527 528 529 530 531
    driver.error(driver.loc_, "Overflow escape in " + std::string(yytext));
}

"["    { return AgentParser::make_LSQUARE_BRACKET(driver.loc_); }
"]"    { return AgentParser::make_RSQUARE_BRACKET(driver.loc_); }
"{"    { return AgentParser::make_LCURLY_BRACKET(driver.loc_); }
"}"    { return AgentParser::make_RCURLY_BRACKET(driver.loc_); }
","    { return AgentParser::make_COMMA(driver.loc_); }
":"    { return AgentParser::make_COLON(driver.loc_); }

{int} {
532
    /* An integer was found. */
533 534 535
    std::string tmp(yytext);
    int64_t integer = 0;
    try {
536 537 538 539
        /* In substring we want to use negative values (e.g. -1).
           In enterprise-id we need to use values up to 0xffffffff.
           To cover both of those use cases, we need at least
           int64_t. */
540 541 542 543 544
        integer = boost::lexical_cast<int64_t>(tmp);
    } catch (const boost::bad_lexical_cast &) {
        driver.error(driver.loc_, "Failed to convert " + tmp + " to an integer.");
    }

545
    /* The parser needs the string form as double conversion is no lossless */
546 547 548 549
    return AgentParser::make_INTEGER(integer, driver.loc_);
}

[-+]?[0-9]*\.?[0-9]*([eE][-+]?[0-9]+)? {
550
    /* A floating point was found. */
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594
    std::string tmp(yytext);
    double fp = 0.0;
    try {
        fp = boost::lexical_cast<double>(tmp);
    } catch (const boost::bad_lexical_cast &) {
        driver.error(driver.loc_, "Failed to convert " + tmp + " to a floating point.");
    }

    return AgentParser::make_FLOAT(fp, driver.loc_);
}

true|false {
    string tmp(yytext);
    return AgentParser::make_BOOLEAN(tmp == "true", driver.loc_);
}

null {
   return AgentParser::make_NULL_TYPE(driver.loc_);
}

(?i:true) driver.error (driver.loc_, "JSON true reserved keyword is lower case only");

(?i:false) driver.error (driver.loc_, "JSON false reserved keyword is lower case only");

(?i:null) driver.error (driver.loc_, "JSON null reserved keyword is lower case only");

<*>.   driver.error (driver.loc_, "Invalid character: " + std::string(yytext));

<<EOF>> {
    if (driver.states_.empty()) {
        return AgentParser::make_END(driver.loc_);
    }
    driver.loc_ = driver.locs_.back();
    driver.locs_.pop_back();
    driver.file_ = driver.files_.back();
    driver.files_.pop_back();
    if (driver.sfile_) {
        fclose(driver.sfile_);
        driver.sfile_ = 0;
    }
    if (!driver.sfiles_.empty()) {
        driver.sfile_ = driver.sfiles_.back();
        driver.sfiles_.pop_back();
    }
Francis Dupont's avatar
Francis Dupont committed
595 596
    agent__delete_buffer(YY_CURRENT_BUFFER);
    agent__switch_to_buffer(driver.states_.back());
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
    driver.states_.pop_back();

    BEGIN(DIR_EXIT);
}

%%

using namespace isc::dhcp;

void
ParserContext::scanStringBegin(const std::string& str, ParserType parser_type)
{
    start_token_flag = true;
    start_token_value = parser_type;

    file_ = "<string>";
    sfile_ = 0;
    loc_.initialize(&file_);
    yy_flex_debug = trace_scanning_;
    YY_BUFFER_STATE buffer;
Francis Dupont's avatar
Francis Dupont committed
617
    buffer = agent__scan_bytes(str.c_str(), str.size());
618 619
    if (!buffer) {
        fatal("cannot scan string");
620
        /* fatal() throws an exception so this can't be reached */
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
    }
}

void
ParserContext::scanFileBegin(FILE * f,
                              const std::string& filename,
                              ParserType parser_type)
{
    start_token_flag = true;
    start_token_value = parser_type;

    file_ = filename;
    sfile_ = f;
    loc_.initialize(&file_);
    yy_flex_debug = trace_scanning_;
    YY_BUFFER_STATE buffer;

638
    /* See agent_lexer.cc header for available definitions */
Francis Dupont's avatar
Francis Dupont committed
639
    buffer = agent__create_buffer(f, 65536 /*buffer size*/);
640 641 642
    if (!buffer) {
        fatal("cannot scan file " + filename);
    }
Francis Dupont's avatar
Francis Dupont committed
643
    agent__switch_to_buffer(buffer);
644 645 646 647 648 649 650
}

void
ParserContext::scanEnd() {
    if (sfile_)
        fclose(sfile_);
    sfile_ = 0;
Francis Dupont's avatar
Francis Dupont committed
651
    static_cast<void>(agent_lex_destroy());
652
    /* Close files */
653 654 655 656 657 658 659
    while (!sfiles_.empty()) {
        FILE* f = sfiles_.back();
        if (f) {
            fclose(f);
        }
        sfiles_.pop_back();
    }
660
    /* Delete states */
661
    while (!states_.empty()) {
Francis Dupont's avatar
Francis Dupont committed
662
        agent__delete_buffer(states_.back());
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682
        states_.pop_back();
    }
}

void
ParserContext::includeFile(const std::string& filename) {
    if (states_.size() > 10) {
        fatal("Too many nested include.");
    }

    FILE* f = fopen(filename.c_str(), "r");
    if (!f) {
        fatal("Can't open include file " + filename);
    }
    if (sfile_) {
        sfiles_.push_back(sfile_);
    }
    sfile_ = f;
    states_.push_back(YY_CURRENT_BUFFER);
    YY_BUFFER_STATE buffer;
Francis Dupont's avatar
Francis Dupont committed
683
    buffer = agent__create_buffer(f, 65536 /*buffer size*/);
684 685 686
    if (!buffer) {
        fatal( "Can't scan include file " + filename);
    }
Francis Dupont's avatar
Francis Dupont committed
687
    agent__switch_to_buffer(buffer);
688 689 690 691 692 693 694 695 696
    files_.push_back(file_);
    file_ = filename;
    locs_.push_back(loc_);
    loc_.initialize(&file_);

    BEGIN(INITIAL);
}

namespace {
697
/** To avoid unused function error */
698
class Dummy {
699
    /* cppcheck-suppress unusedPrivateFunction */
700 701 702
    void dummy() { yy_fatal_error("Fix me: how to disable its definition?"); }
};
}
703
#endif /* !__clang_analyzer__ */