MySQL 8.0.31
Source Code Documentation
parse_location.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 2022, Oracle and/or its affiliates.
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
28/**
29 Helper class for the YYLTYPE
30*/
32 const char *start; // token start
33 const char *end; // the 1st byte after the token
34
35 bool is_empty() const { return length() == 0; }
36 size_t length() const { return static_cast<size_t>(end - start); }
37};
38
39/**
40 Bison "location" class
41*/
42struct YYLTYPE {
43 Symbol_location cpp; // token location in the preprocessed buffer
44 Symbol_location raw; // token location in the raw buffer
45
46 bool is_empty() const { return cpp.is_empty(); }
47};
48
49/*
50 Note: YYLTYPE doesn't overload a default constructor (as well an underlying
51 Symbol_location).
52 OTOH if we need a zero-initialized POS, YYLTYPE or Symbol_location object,
53 we can simply call POS(), YYLTYPE() or Symbol_location(): C++ does
54 value-initialization in that case.
55*/
56typedef YYLTYPE POS;
57
58#define YYLTYPE_IS_DECLARED 1 // signal Bison that we have our own YYLTYPE
59
60/**
61 Bison calls this macro:
62 1. each time a rule is matched and
63 2. to compute a syntax error location.
64
65 @param [out] Current location of the whole matched rule
66 @param Rhs locations of all right hand side elements in the rule
67 @param N number of right hand side elements in the rule
68*/
69#define YYLLOC_DEFAULT(Current, Rhs, N) \
70 do \
71 if (N) { \
72 (Current).cpp.start = YYRHSLOC(Rhs, 1).cpp.start; \
73 (Current).cpp.end = YYRHSLOC(Rhs, N).cpp.end; \
74 (Current).raw.start = YYRHSLOC(Rhs, 1).raw.start; \
75 (Current).raw.end = YYRHSLOC(Rhs, N).raw.end; \
76 } else { \
77 (Current).cpp.start = (Current).cpp.end = YYRHSLOC(Rhs, 0).cpp.end; \
78 (Current).raw.start = (Current).raw.end = YYRHSLOC(Rhs, 0).raw.end; \
79 } \
80 while (0)
81
82#endif /* PARSE_LOCATION_INCLUDED */
YYLTYPE POS
Definition: parse_location.h:56
Helper class for the YYLTYPE.
Definition: parse_location.h:31
bool is_empty() const
Definition: parse_location.h:35
const char * start
Definition: parse_location.h:32
const char * end
Definition: parse_location.h:33
size_t length() const
Definition: parse_location.h:36
Bison "location" class.
Definition: parse_location.h:42
Symbol_location raw
Definition: parse_location.h:44
Symbol_location cpp
Definition: parse_location.h:43
bool is_empty() const
Definition: parse_location.h:46