title: How do I display all pronouns in a sentence and their persons using antlr
body: <p>EDITED according to WayneH's grammar</p>
  
  <p>Here's what i have in my grammar file. </p>
  
  <pre><code>grammar pfinder;
  
  options {
    language = Java;
  }
  sentence
      : ((words | pronoun) SPACE)* ((words | pronoun) ('.' | '?'))
      ;
  
  words 
      :   WORDS {System.out.println($text);};
  
  pronoun returns [String value] 
      : sfirst {$value = $sfirst.value; System.out.println($sfirst.text + '(' + $sfirst.value + ')');}
      | ssecond {$value = $ssecond.value; System.out.println($ssecond.text + '(' + $ssecond.value + ')');}
      | sthird {$value = $sthird.value; System.out.println($sthird.text + '(' + $sthird.value + ')');}
      | pfirst {$value = $pfirst.value; System.out.println($pfirst.text + '(' + $pfirst.value + ')');}
      | psecond {$value = $psecond.value; System.out.println($psecond.text + '(' + $psecond.value + ')');}
      | pthird{$value = $pthird.value; System.out.println($pthird.text + '(' + $pthird.value + ')');};
  
  sfirst returns [String value] :  ('i'   | 'me'  | 'my'   | 'mine') {$value = "s1";};
  ssecond returns [String value] : ('you' | 'your'| 'yours'| 'yourself') {$value = "s2";};
  sthird returns [String value] :  ('he'  | 'she' | 'it'   | 'his' | 'hers' | 'its' | 'him' | 'her' | 'himself' | 'herself') {$value = "s3";};
  pfirst returns [String value] :  ('we'  | 'us'  | 'our'  | 'ours') {$value = "p1";};
  psecond returns [String value] : ('yourselves') {$value = "p2";};
  pthird returns [String value] :  ('they'| 'them'| 'their'| 'theirs' | 'themselves') {$value = "p3";};
  
  WORDS : LETTER*;// {$channel=HIDDEN;}; 
  SPACE : (' ')?;
  fragment LETTER :  ('a'..'z' | 'A'..'Z');
  </code></pre>
  
  <p>and here,s what i have on a java test class</p>
  
  <pre><code>import java.util.Scanner;
  import org.antlr.runtime.*;
  import org.antlr.runtime.tree.*;
  import java.util.List;
  
  public class test2 {
      public static void main(String[] args) throws RecognitionException {
          String s;
          Scanner input = new Scanner(System.in);
          System.out.println("Eter a Sentence: ");
          s=input.nextLine().toLowerCase();
          ANTLRStringStream in = new ANTLRStringStream(s);
          pfinderLexer lexer = new pfinderLexer(in);
          TokenStream tokenStream = new CommonTokenStream(lexer);
          pfinderParser parser = new pfinderParser(tokenStream); 
          parser.pronoun(); 
      }
  }
  </code></pre>
  
  <p>what do I need to put in the test file so that the it will display all the pronouns in a sentence and their respective values(s1,s2,...)?</p>