ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

SourceLocation.hpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel SourceLocation.hpp */
40 /* */
41 /* Primitive Translator Token Class Definitions */
42 /* */
43 /******************************************************************************/
44 #ifndef Included_SourceLocation
45 #define Included_SourceLocation
46 
47 
48 class SourceLocation /* token/clause location information */
49 {
50 public:
51  inline size_t getLineNumber() { return startLine; }
52  inline size_t getOffset() { return startOffset; }
53  inline size_t getEndLine() { return endLine; }
54  inline size_t getEndOffset() { return endOffset; }
55 
56  inline void setLineNumber(size_t l) { startLine = l; }
57  inline void setOffset(size_t l) { startOffset = l; }
58  inline void setEndLine(size_t l) { endLine = l; }
59  inline void setEndOffset(size_t l) { endOffset = l; }
60 
61  inline void setStart(SourceLocation &l)
62  {
64  startOffset = l.getOffset();
65  }
66 
67  inline void setEnd(SourceLocation &l)
68  {
69  setEnd(l.getEndLine(), l.getEndOffset());
70  }
71 
72  inline void setStart(size_t line, size_t offset)
73  {
74  startLine = line;
75  startOffset = offset;
76  }
77 
78  inline void setEnd(size_t line, size_t offset)
79  {
80  // only set if this makes sense
81  if (line > startLine || (line == startLine && offset > startOffset))
82  {
83  endLine = line;
84  endOffset = offset;
85  }
86 
87  }
88 
89  inline void setLocation(size_t line, size_t offset, size_t end, size_t end_offset)
90  {
91  startLine = line;
92  startOffset = offset;
93  endLine = end;
94  endOffset = end_offset;
95  }
96 
97  inline void setLocation(SourceLocation &l)
98  {
99  startLine = l.startLine;
101  endLine = l.endLine;
102  endOffset = l.endOffset;
103  }
104 
105  inline const SourceLocation & operator= (const SourceLocation &l)
106  {
107  startLine = l.startLine;
109  endLine = l.endLine;
110  endOffset = l.endOffset;
111  return *this;
112  }
113 
114 protected:
115  size_t startLine; // file line start location
116  size_t startOffset; // offset within the file line
117  size_t endLine; // file line end location
118  size_t endOffset; // file end offset
119 };
120 
121 
122 #endif
SourceLocation::setStart
void setStart(size_t line, size_t offset)
Definition: SourceLocation.hpp:72
SourceLocation::getOffset
size_t getOffset()
Definition: SourceLocation.hpp:52
SourceLocation::setLocation
void setLocation(SourceLocation &l)
Definition: SourceLocation.hpp:97
SourceLocation::operator=
const SourceLocation & operator=(const SourceLocation &l)
Definition: SourceLocation.hpp:105
SourceLocation::setLineNumber
void setLineNumber(size_t l)
Definition: SourceLocation.hpp:56
SourceLocation::endLine
size_t endLine
Definition: SourceLocation.hpp:117
SourceLocation::getLineNumber
size_t getLineNumber()
Definition: SourceLocation.hpp:51
SourceLocation
Definition: SourceLocation.hpp:48
SourceLocation::endOffset
size_t endOffset
Definition: SourceLocation.hpp:118
SourceLocation::setEndLine
void setEndLine(size_t l)
Definition: SourceLocation.hpp:58
SourceLocation::setEnd
void setEnd(size_t line, size_t offset)
Definition: SourceLocation.hpp:78
SourceLocation::setLocation
void setLocation(size_t line, size_t offset, size_t end, size_t end_offset)
Definition: SourceLocation.hpp:89
SourceLocation::startOffset
size_t startOffset
Definition: SourceLocation.hpp:116
SourceLocation::getEndOffset
size_t getEndOffset()
Definition: SourceLocation.hpp:54
SourceLocation::setOffset
void setOffset(size_t l)
Definition: SourceLocation.hpp:57
SourceLocation::getEndLine
size_t getEndLine()
Definition: SourceLocation.hpp:53
SourceLocation::setEnd
void setEnd(SourceLocation &l)
Definition: SourceLocation.hpp:67
SourceLocation::startLine
size_t startLine
Definition: SourceLocation.hpp:115
SourceLocation::setStart
void setStart(SourceLocation &l)
Definition: SourceLocation.hpp:61
line
char line[65472]
Definition: rxqueue.cpp:81
SourceLocation::setEndOffset
void setEndOffset(size_t l)
Definition: SourceLocation.hpp:59