langtools/src/share/classes/com/sun/tools/javac/parser/Lexer.java
author jjg
Thu, 10 Jun 2010 16:08:01 -0700
changeset 5847 1908176fd6e3
parent 5520 86e4b9a9da40
child 10815 a719aa5f1631
permissions -rw-r--r--
6944312: Potential rebranding issues in openjdk/langtools repository sources Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     1
/*
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     2
 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06bc494ca11e Initial load
duke
parents:
diff changeset
     4
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
06bc494ca11e Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
10
06bc494ca11e Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    10
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
06bc494ca11e Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
06bc494ca11e Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
06bc494ca11e Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
06bc494ca11e Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
06bc494ca11e Initial load
duke
parents:
diff changeset
    16
 *
06bc494ca11e Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
06bc494ca11e Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
06bc494ca11e Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
06bc494ca11e Initial load
duke
parents:
diff changeset
    20
 *
5520
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
86e4b9a9da40 6943119: Rebrand source copyright notices
ohair
parents: 10
diff changeset
    23
 * questions.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    24
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    25
06bc494ca11e Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.javac.parser;
06bc494ca11e Initial load
duke
parents:
diff changeset
    27
06bc494ca11e Initial load
duke
parents:
diff changeset
    28
import com.sun.tools.javac.util.*;
06bc494ca11e Initial load
duke
parents:
diff changeset
    29
import com.sun.tools.javac.util.Position.LineMap;
06bc494ca11e Initial load
duke
parents:
diff changeset
    30
06bc494ca11e Initial load
duke
parents:
diff changeset
    31
/**
06bc494ca11e Initial load
duke
parents:
diff changeset
    32
 * The lexical analyzer maps an input stream consisting of ASCII
06bc494ca11e Initial load
duke
parents:
diff changeset
    33
 * characters and Unicode escapes into a token sequence.
06bc494ca11e Initial load
duke
parents:
diff changeset
    34
 *
5847
1908176fd6e3 6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents: 5520
diff changeset
    35
 * <p><b>This is NOT part of any supported API.
10
06bc494ca11e Initial load
duke
parents:
diff changeset
    36
 * If you write code that depends on this, you do so at your own risk.
06bc494ca11e Initial load
duke
parents:
diff changeset
    37
 * This code and its internal interfaces are subject to change or
06bc494ca11e Initial load
duke
parents:
diff changeset
    38
 * deletion without notice.</b>
06bc494ca11e Initial load
duke
parents:
diff changeset
    39
 */
06bc494ca11e Initial load
duke
parents:
diff changeset
    40
public interface Lexer {
06bc494ca11e Initial load
duke
parents:
diff changeset
    41
06bc494ca11e Initial load
duke
parents:
diff changeset
    42
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    43
     * Has a @deprecated been encountered in last doc comment?
06bc494ca11e Initial load
duke
parents:
diff changeset
    44
     * This needs to be reset by client with resetDeprecatedFlag.
06bc494ca11e Initial load
duke
parents:
diff changeset
    45
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    46
    boolean deprecatedFlag();
06bc494ca11e Initial load
duke
parents:
diff changeset
    47
06bc494ca11e Initial load
duke
parents:
diff changeset
    48
    void resetDeprecatedFlag();
06bc494ca11e Initial load
duke
parents:
diff changeset
    49
06bc494ca11e Initial load
duke
parents:
diff changeset
    50
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    51
     * Returns the documentation string of the current token.
06bc494ca11e Initial load
duke
parents:
diff changeset
    52
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    53
    String docComment();
06bc494ca11e Initial load
duke
parents:
diff changeset
    54
06bc494ca11e Initial load
duke
parents:
diff changeset
    55
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    56
     * Return the last character position of the current token.
06bc494ca11e Initial load
duke
parents:
diff changeset
    57
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    58
    int endPos();
06bc494ca11e Initial load
duke
parents:
diff changeset
    59
06bc494ca11e Initial load
duke
parents:
diff changeset
    60
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    61
     * Return the position where a lexical error occurred;
06bc494ca11e Initial load
duke
parents:
diff changeset
    62
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    63
    int errPos();
06bc494ca11e Initial load
duke
parents:
diff changeset
    64
06bc494ca11e Initial load
duke
parents:
diff changeset
    65
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    66
     * Set the position where a lexical error occurred;
06bc494ca11e Initial load
duke
parents:
diff changeset
    67
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    68
    void errPos(int pos);
06bc494ca11e Initial load
duke
parents:
diff changeset
    69
06bc494ca11e Initial load
duke
parents:
diff changeset
    70
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    71
     * Build a map for translating between line numbers and
06bc494ca11e Initial load
duke
parents:
diff changeset
    72
     * positions in the input.
06bc494ca11e Initial load
duke
parents:
diff changeset
    73
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    74
     * @return a LineMap
06bc494ca11e Initial load
duke
parents:
diff changeset
    75
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    76
    LineMap getLineMap();
06bc494ca11e Initial load
duke
parents:
diff changeset
    77
06bc494ca11e Initial load
duke
parents:
diff changeset
    78
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    79
     * Returns a copy of the input buffer, up to its inputLength.
06bc494ca11e Initial load
duke
parents:
diff changeset
    80
     * Unicode escape sequences are not translated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    81
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    82
    char[] getRawCharacters();
06bc494ca11e Initial load
duke
parents:
diff changeset
    83
06bc494ca11e Initial load
duke
parents:
diff changeset
    84
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
    85
     * Returns a copy of a character array subset of the input buffer.
06bc494ca11e Initial load
duke
parents:
diff changeset
    86
     * The returned array begins at the <code>beginIndex</code> and
06bc494ca11e Initial load
duke
parents:
diff changeset
    87
     * extends to the character at index <code>endIndex - 1</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    88
     * Thus the length of the substring is <code>endIndex-beginIndex</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    89
     * This behavior is like
06bc494ca11e Initial load
duke
parents:
diff changeset
    90
     * <code>String.substring(beginIndex, endIndex)</code>.
06bc494ca11e Initial load
duke
parents:
diff changeset
    91
     * Unicode escape sequences are not translated.
06bc494ca11e Initial load
duke
parents:
diff changeset
    92
     *
06bc494ca11e Initial load
duke
parents:
diff changeset
    93
     * @param beginIndex the beginning index, inclusive.
06bc494ca11e Initial load
duke
parents:
diff changeset
    94
     * @param endIndex the ending index, exclusive.
06bc494ca11e Initial load
duke
parents:
diff changeset
    95
     * @throws IndexOutOfBounds if either offset is outside of the
06bc494ca11e Initial load
duke
parents:
diff changeset
    96
     *         array bounds
06bc494ca11e Initial load
duke
parents:
diff changeset
    97
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
    98
    char[] getRawCharacters(int beginIndex, int endIndex);
06bc494ca11e Initial load
duke
parents:
diff changeset
    99
06bc494ca11e Initial load
duke
parents:
diff changeset
   100
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   101
     * Return the name of an identifier or token for the current token.
06bc494ca11e Initial load
duke
parents:
diff changeset
   102
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   103
    Name name();
06bc494ca11e Initial load
duke
parents:
diff changeset
   104
06bc494ca11e Initial load
duke
parents:
diff changeset
   105
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   106
     * Read token.
06bc494ca11e Initial load
duke
parents:
diff changeset
   107
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   108
    void nextToken();
06bc494ca11e Initial load
duke
parents:
diff changeset
   109
06bc494ca11e Initial load
duke
parents:
diff changeset
   110
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   111
     * Return the current token's position: a 0-based
06bc494ca11e Initial load
duke
parents:
diff changeset
   112
     *  offset from beginning of the raw input stream
06bc494ca11e Initial load
duke
parents:
diff changeset
   113
     *  (before unicode translation)
06bc494ca11e Initial load
duke
parents:
diff changeset
   114
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   115
    int pos();
06bc494ca11e Initial load
duke
parents:
diff changeset
   116
06bc494ca11e Initial load
duke
parents:
diff changeset
   117
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   118
     * Return the last character position of the previous token.
06bc494ca11e Initial load
duke
parents:
diff changeset
   119
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   120
    int prevEndPos();
06bc494ca11e Initial load
duke
parents:
diff changeset
   121
06bc494ca11e Initial load
duke
parents:
diff changeset
   122
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   123
     * Return the radix of a numeric literal token.
06bc494ca11e Initial load
duke
parents:
diff changeset
   124
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   125
    int radix();
06bc494ca11e Initial load
duke
parents:
diff changeset
   126
06bc494ca11e Initial load
duke
parents:
diff changeset
   127
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   128
     * The value of a literal token, recorded as a string.
06bc494ca11e Initial load
duke
parents:
diff changeset
   129
     *  For integers, leading 0x and 'l' suffixes are suppressed.
06bc494ca11e Initial load
duke
parents:
diff changeset
   130
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   131
    String stringVal();
06bc494ca11e Initial load
duke
parents:
diff changeset
   132
06bc494ca11e Initial load
duke
parents:
diff changeset
   133
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   134
     * Return the current token, set by nextToken().
06bc494ca11e Initial load
duke
parents:
diff changeset
   135
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   136
    Token token();
06bc494ca11e Initial load
duke
parents:
diff changeset
   137
06bc494ca11e Initial load
duke
parents:
diff changeset
   138
    /**
06bc494ca11e Initial load
duke
parents:
diff changeset
   139
     * Sets the current token.
06bc494ca11e Initial load
duke
parents:
diff changeset
   140
     */
06bc494ca11e Initial load
duke
parents:
diff changeset
   141
    void token(Token token);
06bc494ca11e Initial load
duke
parents:
diff changeset
   142
}