summaryrefslogtreecommitdiff
path: root/src/main/java/io/devnulllabs/openjava/syntax/SyntaxRule.java
blob: 9d767bcadcca48efa334a92e4c2d5683f85a9c00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
 * SyntaxRule.java
 *
 * comments here.
 *
 * @author   Michiaki Tatsubori
 * @version  %VERSION% %DATE%
 * @see      java.lang.Object
 *
 * COPYRIGHT 1998 by Michiaki Tatsubori, ALL RIGHTS RESERVED.
 */
package io.devnulllabs.openjava.syntax;

import io.devnulllabs.openjava.ptree.ParseTree;

/**
 * The interface <code>SyntaxRule</code> represents a syntax rule.
 * <p>
 *
 * @author   Michiaki Tatsubori
 * @version  1.0
 * @since    $Id: SyntaxRule.java,v 1.2 2003/02/19 02:54:31 tatsubori Exp $
 * @see java.lang.Object
 */
public interface SyntaxRule extends TokenID {
    /**
     * Consumes tokens from the given token source following
     * the rule.
     *
     * @param  token_src token source to consume.
     * @return null in case of fail to consume, otherwise a parse tree
     *         object consumed following this rule.
     * @exception SyntaxException in case to fail to consume.
     */
    public ParseTree consume(TokenSource token_src) throws SyntaxException;

    /**
     * Tests if the given token source follows this rule.
     *
     * @param  token_src token source to consume.
     * @return true if the given token source can be consumed safely.
     */
    public boolean lookahead(TokenSource token_src);

    /**
     * Returns the last syntax exception in consuming token source
     * through the method <tt>consume(TokenSource)</tt>.
     *
     * @return the syntax exception.
     */
    public SyntaxException getSyntaxException();
}