13447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein/* 23447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein [The "BSD license"] 33447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein Copyright (c) 2005-2009 Terence Parr 43447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein All rights reserved. 53447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 63447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein Redistribution and use in source and binary forms, with or without 73447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein modification, are permitted provided that the following conditions 83447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein are met: 93447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 1. Redistributions of source code must retain the above copyright 103447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein notice, this list of conditions and the following disclaimer. 113447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 2. Redistributions in binary form must reproduce the above copyright 123447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein notice, this list of conditions and the following disclaimer in the 133447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein documentation and/or other materials provided with the distribution. 143447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 3. The name of the author may not be used to endorse or promote products 153447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein derived from this software without specific prior written permission. 163447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 173447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 183447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 193447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 203447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 213447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 223447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 263447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 283447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinpackage org.antlr.runtime; 293447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein 30324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruverimport org.antlr.runtime.tree.CommonTree; 31324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 323447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein/** Rules that return more than a single value must return an object 333447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * containing all the values. Besides the properties defined in 343447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * RuleLabelScope.predefinedRulePropertiesScope there may be user-defined 353447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * return values. This class simply defines the minimum properties that 363447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * are always defined and methods to access the others that might be 373447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * available depending on output option such as template and tree. 383447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * 393447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * Note text is not an actual property of the return value, it is computed 403447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * from start and stop using the input stream's toString() method. I 413447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * could add a ctor to this so that we can pass in and store the input 423447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * stream, but I'm not sure we want to do that. It would seem to be undefined 433447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * to get the .text property anyway if the rule matches tokens from multiple 443447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * input streams. 453447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * 463447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * I do not use getters for fields of objects that are used simply to 473447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * group values such as this aggregate. The getters/setters are there to 483447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein * satisfy the superclass interface. 493447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein */ 503447a5916aa62f44de24cc441fc9987116ddff52Andrew Sappersteinpublic class ParserRuleReturnScope extends RuleReturnScope { 513447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public Token start, stop; 523447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public Object getStart() { return start; } 533447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein public Object getStop() { return stop; } 54324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 55324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver public Object tree; // only used when output=AST 56324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver public Object getTree() { return tree; } 573447a5916aa62f44de24cc441fc9987116ddff52Andrew Sapperstein} 58