MySQL  8.0.18
Source Code Documentation
parse_location.h
Go to the documentation of this file.
1 /* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License, version 2.0,
5  as published by the Free Software Foundation.
6 
7  This program is also distributed with certain software (including
8  but not limited to OpenSSL) that is licensed under separate terms,
9  as designated in a particular file or component or in included license
10  documentation. The authors of MySQL hereby grant you an additional
11  permission to link the program and your derivative works with the
12  separately licensed software that they have included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22 
23 #ifndef PARSE_LOCATION_INCLUDED
24 #define PARSE_LOCATION_INCLUDED
25 
26 #include <cstdlib> // size_t
27 #include "my_config.h"
28 
29 /**
30  Helper class for the YYLTYPE
31 */
33  const char *start; // token start
34  const char *end; // the 1st byte after the token
35 
36  bool is_empty() const { return length() == 0; }
37  size_t length() const { return static_cast<size_t>(end - start); }
38 };
39 
40 /**
41  Bison "location" class
42 */
43 struct YYLTYPE {
44  Symbol_location cpp; // token location in the preprocessed buffer
45  Symbol_location raw; // token location in the raw buffer
46 
47  bool is_empty() const { return cpp.is_empty(); }
48 };
49 
50 #define YYLTYPE_IS_DECLARED 1 // signal Bison that we have our own YYLTYPE
51 
52 /**
53  Bison calls this macro:
54  1. each time a rule is matched and
55  2. to compute a syntax error location.
56 
57  @param [out] Current location of the whole matched rule
58  @param Rhs locations of all right hand side elements in the rule
59  @param N number of right hand side elements in the rule
60 */
61 #define YYLLOC_DEFAULT(Current, Rhs, N) \
62  do \
63  if (N) { \
64  (Current).cpp.start = YYRHSLOC(Rhs, 1).cpp.start; \
65  (Current).cpp.end = YYRHSLOC(Rhs, N).cpp.end; \
66  (Current).raw.start = YYRHSLOC(Rhs, 1).raw.start; \
67  (Current).raw.end = YYRHSLOC(Rhs, N).raw.end; \
68  } else { \
69  (Current).cpp.start = (Current).cpp.end = YYRHSLOC(Rhs, 0).cpp.end; \
70  (Current).raw.start = (Current).raw.end = YYRHSLOC(Rhs, 0).raw.end; \
71  } \
72  while (0)
73 
74 #endif /* PARSE_LOCATION_INCLUDED */
const char * start
Definition: parse_location.h:33
const char * end
Definition: parse_location.h:34
size_t length() const
Definition: parse_location.h:37
Helper class for the YYLTYPE.
Definition: parse_location.h:32
bool is_empty() const
Definition: parse_location.h:47
Bison "location" class.
Definition: parse_location.h:43
bool is_empty() const
Definition: parse_location.h:36
Symbol_location raw
Definition: parse_location.h:45
Symbol_location cpp
Definition: parse_location.h:44