Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: openjava/syntax/PrepPhraseRule.java


1   /*
2    * PrepPhraseRule.java
3    *
4    * comments here.
5    *
6    * @author   Michiaki Tatsubori
7    * @version  %VERSION% %DATE%
8    * @see      java.lang.Object
9    *
10   * COPYRIGHT 1999 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
11   */
12  package openjava.syntax;
13  
14  import openjava.ptree.ParseTree;
15  
16  /**
17   * The class <code>PrepPhraseRule</code> represents the syntax rule
18   * of a prepositional phrase.
19   * Suppose there's a syntax rule <code>A</code> and a given identifier
20   * <code>i</code>.  This class can represent the syntax:
21   * <pre>
22   * PrepPhraseRule := i A
23   * </pre>
24   * <p>
25   *
26   * @author   Michiaki Tatsubori
27   * @version  1.0
28   * @since    $Id: PrepPhraseRule.java,v 1.2 2003/02/19 02:54:31 tatsubori Exp $
29   * @see java.lang.Object
30   */
31  public class PrepPhraseRule extends AbstractSyntaxRule {
32  
33    private String prep;
34    private SyntaxRule words;
35  
36    /**
37     * Allocates a new rule representing the syntax of a prepositional
38     * phrase consisting of a preposition and a syntax.
39     */
40    public PrepPhraseRule(String prep, SyntaxRule words) {
41      this.prep = prep;
42      this.words = words;
43    }
44  
45    public ParseTree consume(TokenSource token_src) throws SyntaxException {
46      IdentifierRule ident = new IdentifierRule(prep);
47      ident.consume(token_src);
48      return words.consume(token_src);
49    }
50  
51  }