MySQL 8.0.37
Source Code Documentation
parse_location.h
Go to the documentation of this file.
1/* Copyright (c) 2013, 2024, 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 designed to work 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 either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef PARSE_LOCATION_INCLUDED
25#define PARSE_LOCATION_INCLUDED
26
27#include <cstdlib> // size_t
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*/
43struct 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/*
51 Note: YYLTYPE doesn't overload a default constructor (as well an underlying
52 Symbol_location).
53 OTOH if we need a zero-initialized POS, YYLTYPE or Symbol_location object,
54 we can simply call POS(), YYLTYPE() or Symbol_location(): C++ does
55 value-initialization in that case.
56*/
57typedef YYLTYPE POS;
58
59#define YYLTYPE_IS_DECLARED 1 // signal Bison that we have our own YYLTYPE
60
61/**
62 Bison calls this macro:
63 1. each time a rule is matched and
64 2. to compute a syntax error location.
65
66 @param [out] Current location of the whole matched rule
67 @param Rhs locations of all right hand side elements in the rule
68 @param N number of right hand side elements in the rule
69*/
70#define YYLLOC_DEFAULT(Current, Rhs, N) \
71 do \
72 if (N) { \
73 (Current).cpp.start = YYRHSLOC(Rhs, 1).cpp.start; \
74 (Current).cpp.end = YYRHSLOC(Rhs, N).cpp.end; \
75 (Current).raw.start = YYRHSLOC(Rhs, 1).raw.start; \
76 (Current).raw.end = YYRHSLOC(Rhs, N).raw.end; \
77 } else { \
78 (Current).cpp.start = (Current).cpp.end = YYRHSLOC(Rhs, 0).cpp.end; \
79 (Current).raw.start = (Current).raw.end = YYRHSLOC(Rhs, 0).raw.end; \
80 } \
81 while (0)
82
83#endif /* PARSE_LOCATION_INCLUDED */
YYLTYPE POS
Definition: parse_location.h:57
Helper class for the YYLTYPE.
Definition: parse_location.h:32
bool is_empty() const
Definition: parse_location.h:36
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
Bison "location" class.
Definition: parse_location.h:43
Symbol_location raw
Definition: parse_location.h:45
Symbol_location cpp
Definition: parse_location.h:44
bool is_empty() const
Definition: parse_location.h:47