1 package org.antlr.runtime 2 { 3 /** Rules that return more than a single value must return an object 4 * containing all the values. Besides the properties defined in 5 * RuleLabelScope.predefinedRulePropertiesScope there may be user-defined 6 * return values. This class simply defines the minimum properties that 7 * are always defined and methods to access the others that might be 8 * available depending on output option such as template and tree. 9 * 10 * Note text is not an actual property of the return value, it is computed 11 * from start and stop using the input stream's toString() method. I 12 * could add a ctor to this so that we can pass in and store the input 13 * stream, but I'm not sure we want to do that. It would seem to be undefined 14 * to get the .text property anyway if the rule matches tokens from multiple 15 * input streams. 16 * 17 * I do not use getters for fields of objects that are used simply to 18 * group values such as this aggregate. 19 */ 20 public class ParserRuleReturnScope extends RuleReturnScope { 21 private var _startToken:Token; 22 private var _stopToken:Token; 23 private var _tree:Object; // if output=AST this contains the tree 24 private var _values:Object = new Object(); // contains the return values 25 26 public override function get start():Object { 27 return _startToken; 28 } 29 30 public function set start(token:Object):void { 31 _startToken = Token(token); 32 } 33 34 public override function get stop():Object { 35 return _stopToken; 36 } 37 38 public function set stop(token:Object):void { 39 _stopToken = Token(token); 40 } 41 42 /** Has a value potentially if output=AST; */ 43 public override function get tree():Object { 44 return _tree; 45 } 46 47 public function set tree(tree:Object):void { 48 _tree = tree; 49 } 50 51 public function get values():Object { 52 return _values; 53 } 54 } 55 }