View Javadoc

1   package org.codehaus.groovy.syntax.lexer;
2   
3   /*
4    $Id: CharStream.java,v 1.5 2004/02/26 17:46:20 jstrachan Exp $
5   
6    Copyright 2003 (C) James Strachan and Bob Mcwhirter. All Rights Reserved.
7   
8    Redistribution and use of this software and associated documentation
9    ("Software"), with or without modification, are permitted provided
10   that the following conditions are met:
11  
12   1. Redistributions of source code must retain copyright
13      statements and notices.  Redistributions must also contain a
14      copy of this document.
15  
16   2. Redistributions in binary form must reproduce the
17      above copyright notice, this list of conditions and the
18      following disclaimer in the documentation and/or other
19      materials provided with the distribution.
20  
21   3. The name "groovy" must not be used to endorse or promote
22      products derived from this Software without prior written
23      permission of The Codehaus.  For written permission,
24      please contact info@codehaus.org.
25  
26   4. Products derived from this Software may not be called "groovy"
27      nor may "groovy" appear in their names without prior written
28      permission of The Codehaus. "groovy" is a registered
29      trademark of The Codehaus.
30  
31   5. Due credit should be given to The Codehaus -
32      http://groovy.codehaus.org/
33  
34   THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
35   ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
36   NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
37   FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
38   THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
39   INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
40   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
41   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
42   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
43   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
45   OF THE POSSIBILITY OF SUCH DAMAGE.
46  
47   */
48  
49  import org.codehaus.groovy.syntax.ReadException;
50  
51  /*** Conduit of characters  to a lexer.
52   *
53   *  @see Lexer
54   *  @see AbstractCharStream
55   *
56   *  @author <a href="mailto:bob@werken.com">bob mcwhirter</a>
57   *
58   *  @version $Id: CharStream.java,v 1.5 2004/02/26 17:46:20 jstrachan Exp $
59   */
60  public interface CharStream {
61      // ----------------------------------------------------------------------
62      //     Constants
63      // ----------------------------------------------------------------------
64  
65      /*** End-of-stream value. */
66      final char EOS = (char) - 1;
67  
68      // ----------------------------------------------------------------------
69      //     Interface
70      // ----------------------------------------------------------------------
71  
72      String getDescription();
73  
74      /*** Consume the next character.
75       *
76       *  @return The consumed character or -1 if no more characters
77       *          available.
78       *
79       *  @throws ReadException If an error occurs attempting to consume
80       *          a character.
81       */
82      char consume() throws ReadException;
83  
84      void close() throws ReadException;
85  }