org.eclipse.mtl.parser.cst
Class CSTParser

java.lang.Object
  extended by org.eclipse.mtl.parser.cst.CSTParser

public class CSTParser
extends java.lang.Object

The main class of the CST creator. Creates a CST model from a MTL file. You just have to launch the 'parse' method...


Field Summary
protected  CSTParserBlock pBlock
          To parse a block statement in the text : 'for', 'if'...
protected  SequenceBlock pBrackets
          To parse a 'brackets' block in the text.
protected  Sequence pComma
          To parse a 'comma' sequence in the text.
protected  SequenceBlock pComment
          To parse a 'comment' block in the text.
protected  Sequence pGuard
          To parse a 'guard' sequence in the text.
protected  SequenceBlock pImport
          To parse an 'import' block in the text.
protected  SequenceBlock pLiteral
          To parse a 'literal' block in the text.
protected  SequenceBlock pMacro
          To parse a 'macro' block in the text.
protected  SequenceBlock pModule
          To parse a 'module' block in the text.
protected  SequenceBlock pParenthesis
          To parse a 'parenthesis' block in the text.
protected  Sequence pPipe
          To parse a 'pipe' sequence in the text.
protected  SequenceBlock pQuery
          To parse a 'query' block in the text.
protected  Sequence pSemicolon
          To parse a 'semicolon' sequence in the text.
protected  SequenceBlock pTemplate
          To parse a 'template' block in the text.
protected  MTLSourceBuffer source
          The source buffer to parse.
 
Constructor Summary
CSTParser(MTLSourceBuffer source)
          Constructor.
 
Method Summary
 Variable createVariable(int posBegin, int posEnd, Module eModule)
          Creates a new variable in the CST model by reading the following text between the given delimiters.
protected  Variable[] createVariablesCommaSeparator(int posBegin, int posEnd, Module eModule)
          Creates new variables in the CST model by reading the following text between the given delimiters.
protected  Module getModule(org.eclipse.emf.ecore.EObject eObject)
          Gets the current module for the given object of the CST model.
 CSTParserBlock getPBlock()
          Gets the block parser, for the statement : 'for', 'if'...
 MTLSourceBuffer getSource()
          Gets the source buffer to parse.
 Module parse()
          Creates a CST model for the file.
 void parseMacroBody(int posBegin, int posEnd, Macro eMacro)
          Reads the information of the 'macro' body in the text, and modifies the children of the current CST node.
 void parseMacroHeader(int posBegin, int posEnd, Macro eMacro)
          Reads the information of the 'macro' header in the text, and modifies the properties of the current CST node.
 void parseModuleBody(int posBegin, int posEnd, Module eModule)
          Reads the information of the 'module' body in the text, and modifies the children of the current CST node.
 void parseModuleHeader(int posBegin, int posEnd, Module eModule)
          Reads the information of the 'module' header in the text, and modifies the properties of the current CST node.
 void parseQueryHeader(int posBegin, int posEnd, Query eQuery)
          Reads the information of the 'query' header in the text, and modifies the properties of the current CST node.
 void parseTemplateBody(int posBegin, int posEnd, Template eTemplate)
          Reads the information of the 'template' body in the text, and modifies the children of the current CST node.
 void parseTemplateHeader(int posBegin, int posEnd, Template eTemplate)
          Reads the information of the 'template' header in the text, and modifies the properties of the current CST node.
protected  void setPositions(CSTNode eCSTNode, int posBegin, int posEnd)
          To store the position in the CST node.
protected  int shiftInitSectionBody(int posBegin, int posEnd, Block eBlock)
          Reads eventually the following text as a new 'init section' (header and body) in the CST model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected final MTLSourceBuffer source
The source buffer to parse.


pLiteral

protected final SequenceBlock pLiteral
To parse a 'literal' block in the text.


pComment

protected final SequenceBlock pComment
To parse a 'comment' block in the text.


pParenthesis

protected final SequenceBlock pParenthesis
To parse a 'parenthesis' block in the text.


pBrackets

protected final SequenceBlock pBrackets
To parse a 'brackets' block in the text.


pComma

protected final Sequence pComma
To parse a 'comma' sequence in the text.


pSemicolon

protected final Sequence pSemicolon
To parse a 'semicolon' sequence in the text.


pPipe

protected final Sequence pPipe
To parse a 'pipe' sequence in the text.


pGuard

protected final Sequence pGuard
To parse a 'guard' sequence in the text.


pModule

protected final SequenceBlock pModule
To parse a 'module' block in the text.


pImport

protected final SequenceBlock pImport
To parse an 'import' block in the text.


pTemplate

protected final SequenceBlock pTemplate
To parse a 'template' block in the text.


pMacro

protected final SequenceBlock pMacro
To parse a 'macro' block in the text.


pQuery

protected final SequenceBlock pQuery
To parse a 'query' block in the text.


pBlock

protected final CSTParserBlock pBlock
To parse a block statement in the text : 'for', 'if'...

Constructor Detail

CSTParser

public CSTParser(MTLSourceBuffer source)
Constructor.

Parameters:
source - is the source buffer to parse
Method Detail

getSource

public MTLSourceBuffer getSource()
Gets the source buffer to parse.

Returns:
the source buffer

getPBlock

public CSTParserBlock getPBlock()
Gets the block parser, for the statement : 'for', 'if'...

Returns:
the block parser

setPositions

protected void setPositions(CSTNode eCSTNode,
                            int posBegin,
                            int posEnd)
To store the position in the CST node.

Parameters:
eCSTNode - is the node to update
posBegin - is the beginning index
posEnd - is the ending index

parse

public Module parse()
Creates a CST model for the file.

Returns:
the root object of the CST model

parseModuleHeader

public void parseModuleHeader(int posBegin,
                              int posEnd,
                              Module eModule)
Reads the information of the 'module' header in the text, and modifies the properties of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eModule - is the current object of the CST model, it will be modified in this method

parseModuleBody

public void parseModuleBody(int posBegin,
                            int posEnd,
                            Module eModule)
Reads the information of the 'module' body in the text, and modifies the children of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eModule - is the current object of the CST model, it will be modified in this method

parseTemplateHeader

public void parseTemplateHeader(int posBegin,
                                int posEnd,
                                Template eTemplate)
Reads the information of the 'template' header in the text, and modifies the properties of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eTemplate - is the current object of the CST model, it will be modified in this method

shiftInitSectionBody

protected int shiftInitSectionBody(int posBegin,
                                   int posEnd,
                                   Block eBlock)
Reads eventually the following text as a new 'init section' (header and body) in the CST model.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eBlock - is the current object of the CST model, it will be modified in this method
Returns:
the ending index of the init section, or the beginning index if it doesn't exist

createVariablesCommaSeparator

protected Variable[] createVariablesCommaSeparator(int posBegin,
                                                   int posEnd,
                                                   Module eModule)
Creates new variables in the CST model by reading the following text between the given delimiters. A comma separator is considered between each variable.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eModule - is the module of the CST model, it is used to get the model types...
Returns:
the new variables

createVariable

public Variable createVariable(int posBegin,
                               int posEnd,
                               Module eModule)
Creates a new variable in the CST model by reading the following text between the given delimiters.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eModule - is the module of the CST model, it is used to get the model types...
Returns:
the new variable

getModule

protected Module getModule(org.eclipse.emf.ecore.EObject eObject)
Gets the current module for the given object of the CST model.

Parameters:
eObject - is an object of the CST model
Returns:
the current module

parseTemplateBody

public void parseTemplateBody(int posBegin,
                              int posEnd,
                              Template eTemplate)
Reads the information of the 'template' body in the text, and modifies the children of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eTemplate - is the current object of the CST model, it will be modified in this method

parseQueryHeader

public void parseQueryHeader(int posBegin,
                             int posEnd,
                             Query eQuery)
Reads the information of the 'query' header in the text, and modifies the properties of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eQuery - is the current object of the CST model, it will be modified in this method

parseMacroHeader

public void parseMacroHeader(int posBegin,
                             int posEnd,
                             Macro eMacro)
Reads the information of the 'macro' header in the text, and modifies the properties of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eMacro - is the current object of the CST model, it will be modified in this method

parseMacroBody

public void parseMacroBody(int posBegin,
                           int posEnd,
                           Macro eMacro)
Reads the information of the 'macro' body in the text, and modifies the children of the current CST node.

Parameters:
posBegin - is the beginning index
posEnd - is the ending index
eMacro - is the current object of the CST model, it will be modified in this method

Copyright 2008 Obeo
All Rights Reserved.