Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## javafe.parser
Class ParseUtil

    java.lang.Object
      javafe.parser.ParseUtil

Direct Known Subclasses:
  ParseType

public class ParseUtil
extends java.lang.Object

Base class for Java parser; provides some basic parsing utilities.

See Also:
  `ASTNode`, `ParseType`, `Parse`

Field Summary
`static int[]` | `modifierKeywords` Keyword at index i in this array corresponds to bit i in modifier bitset.
`ModifierPragmaVec` | `modifierPragmas` As a side effect, `parseModifiers` mutates this value.
`protected StackVector` | `seqModifierPragma`

Constructor Summary
`ParseUtil()`

Method Summary
`static java.lang.String` | `arrayToString(java.lang.Object[] a, java.lang.String sep)`
`static void` | `error(int loc, java.lang.String m)`
`void` | `expect(Lex l, int expected)` Takes an expected token from the input stream, calls `fail` on error.
`static void` | `fail(int loc, java.lang.String m)` Raises a `RuntimeException` with the argument string including a textual representation of the given source location.
`int` | `getJavaModifier(Lex l, int modifiers)` Checks if the next token is a Java modifier.
`boolean` | `isJavaModifier(int ttype)`
`(package private) int` | `operatorTokenToTag(int token)` Converts operator tokens to corresponding AST tag.
`ModifierPragmaVec` | `parseModifierPragmas(Lex l)` Parse a list of modifier pragmas.
`int` | `parseModifiers(Lex l)` Parse a list of modifiers.
`ModifierPragmaVec` | `parseMoreModifierPragmas(Lex l, ModifierPragmaVec orig)` Parse a list of modifier pragmas and adds them to an existing `ModifierPragmaVec`.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### seqModifierPragma

    protected final StackVector seqModifierPragma

### modifierKeywords

    public static final int[] modifierKeywords

  Keyword at index i in this array corresponds to bit i in modifier bitset. Thus PRIVATE is at index 1, ACC_PRIVATE = 1<<1. These are in the same bit order as the values in java.lang.reflect.Modifier, and should remain that way, though I don't know if any code uses that fact (it might come in handy in reading class files, for example).

### modifierPragmas

    public ModifierPragmaVec modifierPragmas

  As a side effect, `parseModifiers` mutates this value.

Constructor Detail

### ParseUtil

    public ParseUtil()

Method Detail

### fail

    public static void fail(int loc,
                            java.lang.String m)

  Raises a `RuntimeException` with the argument string including a textual representation of the given source location.

### error

    public static void error(int loc,
                             java.lang.String m)

### expect

    public void expect(Lex l,
                       int expected)

  Takes an expected token from the input stream, calls `fail` on error.

### operatorTokenToTag

    int operatorTokenToTag(int token)

  Converts operator tokens to corresponding AST tag. Tokens INC and DEC get mapped to PREFIXINC and PREFIXDEC

### parseModifierPragmas

    public ModifierPragmaVec parseModifierPragmas(Lex l)

  Parse a list of modifier pragmas. Returns `null` if `l` does not point to a modifier pragma. Otherwise, reads `l` until there are no more modifier pragmas and returns the resulting list.

### parseMoreModifierPragmas

    public ModifierPragmaVec parseMoreModifierPragmas(Lex l,
                                                      ModifierPragmaVec orig)

  Parse a list of modifier pragmas and adds them to an existing `ModifierPragmaVec`. If the existing `ModifierPragmaVec` was `null`, then it either returns `null` (if `l` does not point to a modifier pragma), or returns a new `ModifierPragmaVec`.

### parseModifiers

    public int parseModifiers(Lex l)

  Parse a list of modifiers. Ensures no duplicate Java modifiers and only one of the access modifiers public, protected, private. Return integer encoding the Java modifiers.

  In addition to parsing Java modifiers, also handles modifier pragmas (anything with a ttype of TagConstants.MODIFIERPRAGMA). If no modifier pragmas are seen, sets modifierPragmas to null. Otherwise, sets it to be the list of modifier pragmas seen in the course of parsing any Java modifiers.

  See Also:
    `Modifiers`

### getJavaModifier

    public int getJavaModifier(Lex l,
                               int modifiers)

  Checks if the next token is a Java modifier. Returns 0 if it is not; returns an int with the modifier bit turned on if it is. Also issues an error if the modifier is already present in the modifiers argument (use 0 for this argument to turn off these errors). Note that the bit that is found is not ORed into the modifiers int; you have to do that outside this call. The Lex is advanced if a modifier is found.

### isJavaModifier

    public boolean isJavaModifier(int ttype)

### arrayToString

    public static java.lang.String arrayToString(java.lang.Object[] a,
                                                 java.lang.String sep)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| ESC/Java2 © 2003,2004,2005 David Cok and Joseph Kiniry © 2005 UCD Dublin © 2003,2004 Radboud University Nijmegen © 1999,2000 Compaq Computer Corporation © 1997,1998,1999 Digital Equipment Corporation All Rights Reserved
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

The ESC/Java2 Project Homepage