1/*
2 * [The "BSD licence"]
3 * Copyright (c) 2011 Terence Parr
4 * All rights reserved.
5 *
6 * Conversion to C#:
7 * Copyright (c) 2011 Sam Harwell, Pixel Mine, Inc.
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 3. The name of the author may not be used to endorse or promote products
19 *    derived from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33namespace Antlr.Runtime
34{
35    using CLSCompliant = System.CLSCompliantAttribute;
36
37    /** <summary>
38     *  Rules that return more than a single value must return an object
39     *  containing all the values.  Besides the properties defined in
40     *  RuleLabelScope.predefinedRulePropertiesScope there may be user-defined
41     *  return values.  This class simply defines the minimum properties that
42     *  are always defined and methods to access the others that might be
43     *  available depending on output option such as template and tree.
44     *  </summary>
45     *
46     *  <remarks>
47     *  Note text is not an actual property of the return value, it is computed
48     *  from start and stop using the input stream's toString() method.  I
49     *  could add a ctor to this so that we can pass in and store the input
50     *  stream, but I'm not sure we want to do that.  It would seem to be undefined
51     *  to get the .text property anyway if the rule matches tokens from multiple
52     *  input streams.
53     *
54     *  I do not use getters for fields of objects that are used simply to
55     *  group values such as this aggregate.  The getters/setters are there to
56     *  satisfy the superclass interface.
57     *  </remarks>
58     */
59    public class ParserRuleReturnScope<TToken> : IRuleReturnScope<TToken>
60    {
61        private TToken _start;
62        private TToken _stop;
63
64        public TToken Start
65        {
66            get
67            {
68                return _start;
69            }
70
71            set
72            {
73                _start = value;
74            }
75        }
76
77        public TToken Stop
78        {
79            get
80            {
81                return _stop;
82            }
83
84            set
85            {
86                _stop = value;
87            }
88        }
89
90        object IRuleReturnScope.Start
91        {
92            get
93            {
94                return Start;
95            }
96        }
97
98        object IRuleReturnScope.Stop
99        {
100            get
101            {
102                return Stop;
103            }
104        }
105    }
106}
107