org.eclipse.mtl.parser.cst.utils
Class ParserUtils

java.lang.Object
  extended by org.eclipse.mtl.parser.cst.utils.ParserUtils

public final class ParserUtils
extends java.lang.Object

Common utilities to parse sequences.


Method Summary
static SequenceBlock createMTLSequenceBlock(boolean headerOnly, java.lang.String name, boolean recursiveBody, SequenceBlock[] inhibsHeader, SequenceBlock[] inhibsBody)
          Creates a MTL block analyzer.
static int getNextSequence(java.lang.StringBuffer buffer, int posBegin, int posEnd, ISequence[] pElements, Region[] pElementsPositions)
          To find the nearest sequence ('pElements') in the buffer.
static int getNextSequence(java.lang.StringBuffer buffer, int posBegin, int posEnd, ISequence[] pElements, Region[] pElementsPositions, SequenceBlock[] pInhibs, Region[] pInhibsPositions)
          To find the nearest sequence ('pElements') in the buffer, and some blocks ('pInhibs') are ignored.
static int shiftIdentifier(java.lang.StringBuffer buffer, int posBegin, int posEnd)
          Reads eventually the following identifier in the text.
static int shiftKeyword(java.lang.StringBuffer buffer, int posBegin, int posEnd, java.lang.String keyword, boolean wholeWord)
          Reads eventually the following text if the given keyword matches.
static int shiftKeyword(java.lang.StringBuffer buffer, int posBegin, int posEnd, java.lang.String keyword, boolean ignoreCase, boolean wholeWord)
          Reads eventually the following text if the given keyword matches.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createMTLSequenceBlock

public static SequenceBlock createMTLSequenceBlock(boolean headerOnly,
                                                   java.lang.String name,
                                                   boolean recursiveBody,
                                                   SequenceBlock[] inhibsHeader,
                                                   SequenceBlock[] inhibsBody)
Creates a MTL block analyzer. It uses the MTL delimiters '[' and ']'.
  • header only : [name ... header ... /]
  • header + body : [name ... header ... ] ... body ... [/name]
  • Parameters:
    headerOnly - indicates if it parses the header only, the body is ignored
    name - is the name of the block
    recursiveBody - indicates if the block cans contain the same block
    inhibsHeader - are the ignored sequences on the header part
    inhibsBody - are the ignored sequences on the body part
    Returns:
    the MTL block analyzer

    getNextSequence

    public static int getNextSequence(java.lang.StringBuffer buffer,
                                      int posBegin,
                                      int posEnd,
                                      ISequence[] pElements,
                                      Region[] pElementsPositions)
    To find the nearest sequence ('pElements') in the buffer.

    Parameters:
    buffer - is the buffer
    posBegin - is the beginning index
    posEnd - is the ending index
    pElements - are the candidates to search
    pElementsPositions - are the previous values computed for the candidates, it is modified in this method
    Returns:
    the index in the tables 'pElements' and in 'pElementsPositions' of the next element

    getNextSequence

    public static int getNextSequence(java.lang.StringBuffer buffer,
                                      int posBegin,
                                      int posEnd,
                                      ISequence[] pElements,
                                      Region[] pElementsPositions,
                                      SequenceBlock[] pInhibs,
                                      Region[] pInhibsPositions)
    To find the nearest sequence ('pElements') in the buffer, and some blocks ('pInhibs') are ignored.

    Parameters:
    buffer - is the buffer
    posBegin - is the beginning index
    posEnd - is the ending index
    pElements - are the candidates to search
    pElementsPositions - are the previous values computed for the candidates, it is modified in this method
    pInhibs - are the blocks to ignore
    pInhibsPositions - are the previous values computed for the ignored blocks, it is modified in this method
    Returns:
    the index in the tables 'pElements' and in 'pElementsPositions' of the next element

    shiftKeyword

    public static int shiftKeyword(java.lang.StringBuffer buffer,
                                   int posBegin,
                                   int posEnd,
                                   java.lang.String keyword,
                                   boolean wholeWord)
    Reads eventually the following text if the given keyword matches. Spaces are ignored.

    Parameters:
    buffer - is the buffer to parse
    posBegin - is the beginning index
    posEnd - is the ending index
    keyword - is the keyword to read in the text at the current index
    wholeWord - indicates if the search mode is 'whole word'
    Returns:
    the ending index of the keyword, or the beginning index if it doesn't exist

    shiftKeyword

    public static int shiftKeyword(java.lang.StringBuffer buffer,
                                   int posBegin,
                                   int posEnd,
                                   java.lang.String keyword,
                                   boolean ignoreCase,
                                   boolean wholeWord)
    Reads eventually the following text if the given keyword matches. Spaces are ignored.

    Parameters:
    buffer - is the buffer to parse
    posBegin - is the beginning index
    posEnd - is the ending index
    keyword - is the keyword to read in the text at the current index
    ignoreCase - indicates if the search mode is 'ignore case'
    wholeWord - indicates if the search mode is 'whole word'
    Returns:
    the ending index of the keyword, or the beginning index if it doesn't exist

    shiftIdentifier

    public static int shiftIdentifier(java.lang.StringBuffer buffer,
                                      int posBegin,
                                      int posEnd)
    Reads eventually the following identifier in the text.

    Parameters:
    buffer - is the buffer to parse
    posBegin - is the beginning index
    posEnd - is the ending index
    Returns:
    the ending index of the identifier, or 'posBegin' if the following text isn't an identifier

    Copyright 2008 Obeo
    All Rights Reserved.