source: trunk/src/generated/location.hh @ 2410

Last change on this file since 2410 was 2410, checked in by touky, 7 years ago

easymesh : Added SmoothMesh operation, works well with triangle, not well with a box.

File size: 4.2 KB
Line 
1/* A Bison parser, made by GNU Bison 2.4.2.  */
2
3/* Locations for Bison parsers in C++
4   
5      Copyright (C) 2002-2007, 2009-2010 Free Software Foundation, Inc.
6   
7   This program is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11   
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16   
17   You should have received a copy of the GNU General Public License
18   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20/* As a special exception, you may create a larger work that contains
21   part or all of the Bison parser skeleton and distribute that work
22   under terms of your choice, so long as that work isn't itself a
23   parser generator using the skeleton or a modified version thereof
24   as a parser skeleton.  Alternatively, if you modify or redistribute
25   the parser skeleton itself, you may (at your option) remove this
26   special exception, which will cause the skeleton and the resulting
27   Bison output files to be licensed under the GNU General Public
28   License without this special exception.
29   
30   This special exception was added by the Free Software Foundation in
31   version 2.2 of Bison.  */
32
33/**
34 ** \file location.hh
35 ** Define the lol::location class.
36 */
37
38#ifndef BISON_LOCATION_HH
39# define BISON_LOCATION_HH
40
41# include <iostream>
42# include <string>
43# include "position.hh"
44
45
46namespace lol {
47
48/* Line 162 of location.cc  */
49#line 50 "generated/location.hh"
50
51  /// Abstract a location.
52  class location
53  {
54  public:
55
56    /// Construct a location.
57    location ()
58      : begin (), end ()
59    {
60    }
61
62
63    /// Initialization.
64    inline void initialize (std::string* fn)
65    {
66      begin.initialize (fn);
67      end = begin;
68    }
69
70    /** \name Line and Column related manipulators
71     ** \{ */
72  public:
73    /// Reset initial location to final location.
74    inline void step ()
75    {
76      begin = end;
77    }
78
79    /// Extend the current location to the COUNT next columns.
80    inline void columns (unsigned int count = 1)
81    {
82      end += count;
83    }
84
85    /// Extend the current location to the COUNT next lines.
86    inline void lines (unsigned int count = 1)
87    {
88      end.lines (count);
89    }
90    /** \} */
91
92
93  public:
94    /// Beginning of the located region.
95    position begin;
96    /// End of the located region.
97    position end;
98  };
99
100  /// Join two location objects to create a location.
101  inline const location operator+ (const location& begin, const location& end)
102  {
103    location res = begin;
104    res.end = end.end;
105    return res;
106  }
107
108  /// Add two location objects.
109  inline const location operator+ (const location& begin, unsigned int width)
110  {
111    location res = begin;
112    res.columns (width);
113    return res;
114  }
115
116  /// Add and assign a location.
117  inline location& operator+= (location& res, unsigned int width)
118  {
119    res.columns (width);
120    return res;
121  }
122
123  /// Compare two location objects.
124  inline bool
125  operator== (const location& loc1, const location& loc2)
126  {
127    return loc1.begin == loc2.begin && loc1.end == loc2.end;
128  }
129
130  /// Compare two location objects.
131  inline bool
132  operator!= (const location& loc1, const location& loc2)
133  {
134    return !(loc1 == loc2);
135  }
136
137  /** \brief Intercept output stream redirection.
138   ** \param ostr the destination output stream
139   ** \param loc a reference to the location to redirect
140   **
141   ** Avoid duplicate information.
142   */
143  inline std::ostream& operator<< (std::ostream& ostr, const location& loc)
144  {
145    position last = loc.end - 1;
146    ostr << loc.begin;
147    if (last.filename
148        && (!loc.begin.filename
149            || *loc.begin.filename != *last.filename))
150      ostr << '-' << last;
151    else if (loc.begin.line != last.line)
152      ostr << '-' << last.line  << '.' << last.column;
153    else if (loc.begin.column != last.column)
154      ostr << '-' << last.column;
155    return ostr;
156  }
157
158
159} // lol
160
161/* Line 271 of location.cc  */
162#line 163 "generated/location.hh"
163
164#endif // not BISON_LOCATION_HH
Note: See TracBrowser for help on using the repository browser.