gate.jape.parser
Class ParseCpsl

java.lang.Object
  extended by gate.jape.parser.ParseCpsl
All Implemented Interfaces:
JapeConstants, ParseCpslConstants, Serializable

public class ParseCpsl
extends Object
implements JapeConstants, ParseCpslConstants

A parser for the CPSL language. Generated using JavaCC.

Author:
Hamish Cunningham
See Also:
Serialized Form

Field Summary
protected  URL baseURL
           
protected  SinglePhaseTransducer curSPT
           
protected  String encoding
           
 Token jj_nt
           
 boolean lookingAhead
           
protected  HashMap macrosMap
          A table of macro definitions.
protected  HashMap templatesMap
          A table of template definitions.
 Token token
           
 ParseCpslTokenManager token_source
           
 
Fields inherited from interface gate.jape.JapeConstants
ALL_STYLE, APPELT_STYLE, BRILL_STYLE, DEFAULT_PRIORITY, FIRST_STYLE, INDENT_PADDING, KLEENE_PLUS, KLEENE_QUERY, KLEENE_STAR, MULTI_SPAN_BINDING, NO_BINDING, NO_KLEENE_OP, ONCE_STYLE, SINGLE_SPAN_BINDING
 
Fields inherited from interface gate.jape.parser.ParseCpslConstants
assign, attrOp, bar, bool, colon, colonplus, comma, commentChars, commentEnd, commentStart, controlleraborted, controllerfinished, controllerstarted, DEFAULT, digits, EOF, exponent, floatingPoint, ident, IN_PHASES, IN_STRING, input, integer, javaimport, kleeneOp, leftBrace, leftBracket, leftSquare, letter, letterOrDigitOrDash, letterOrUnderscore, letters, lettersAndDigits, lettersAndDigitsAndDashes, macro, metaPropOp, multiphase, newline, option, other, path, period, phase, phases, PHASES_WITHIN_COMMENT, phasesCommentChars, phasesCommentEnd, phasesCommentStart, phasesSingleLineCpslStyleComment, phasesSingleLineCStyleComment, phasesWhiteSpace, pling, priority, rightBrace, rightBracket, rightSquare, rule, semicolon, singleLineCpslStyleComment, singleLineCStyleComment, space, spaces, string, template, tokenImage, whiteSpace, WITHIN_COMMENT
 
Constructor Summary
ParseCpsl(InputStream stream)
           
ParseCpsl(InputStream stream, String encoding)
           
ParseCpsl(ParseCpslTokenManager tm)
           
ParseCpsl(Reader stream)
           
ParseCpsl(Reader stream, HashMap existingMacros)
           
ParseCpsl(Reader stream, HashMap existingMacros, HashMap existingTemplates)
           
ParseCpsl(URL url, String encoding)
          Construct from a URL and an encoding
ParseCpsl(URL url, String encoding, HashMap existingMacros)
          Construct from a URL and an encoding
ParseCpsl(URL url, String encoding, HashMap existingMacros, HashMap existingTemplates)
           
 
Method Summary
 MultiPhaseTransducer _MultiPhaseTransducer()
           
 String[] Action(boolean checkLabel)
           
 void addStatusListener(StatusListener listener)
           
 String[] AnonymousJavaBlock()
           
protected  void appendAnnotationAdd(StringBuffer blockBuffer, String newAnnotType, String annotSetName)
           
protected  void appendJavaStringLiteral(StringBuffer buf, String str)
          Append the given string to the end of the given buffer as a Java string literal.
 String[] AssignmentExpression(boolean checkLabel)
           
 Pair AttrVal()
           
 BasicPatternElement BasicPatternElement()
           
 ComplexPatternElement ComplexPatternElement(LeftHandSide lhs)
           
 Constraint Constraint()
           
 void ConstraintGroup(LeftHandSide lhs, ConstraintGroup cg)
           
 String ControllerAbortedBlock()
           
 String ControllerFinishedBlock()
           
 String ControllerStartedBlock()
           
protected  SinglePhaseTransducer createSinglePhaseTransducer(String name)
           
 void disable_tracing()
           
 void enable_tracing()
           
 AnnotationAccessor FeatureAccessor()
           
protected  void finishBPE(BasicPatternElement bpe)
           
protected  void finishSPT(SinglePhaseTransducer t)
           
protected  void fireStatusChangedEvent(String text)
           
 ParseException generateParseException()
           
 Token getNextToken()
           
 Token getToken(int index)
           
 String JavaImportBlock()
           
 KleeneOperator KleeneOperator()
           
 LeftHandSide LeftHandSide()
           
 void MacroDef()
           
 MultiPhaseTransducer MultiPhaseTransducer()
          Attempt to parse a multi phase transducer from the current file.
 String[] NamedJavaBlock(boolean checkLabel)
           
 PatternElement PatternElement(LeftHandSide lhs)
           
 void ReInit(InputStream stream)
           
 void ReInit(InputStream stream, String encoding)
           
 void ReInit(ParseCpslTokenManager tm)
           
 void ReInit(Reader stream)
           
 void removeStatusListener(StatusListener listener)
           
 RightHandSide RightHandSide(String phaseName, String ruleName, LeftHandSide lhs, String imports)
           
 Rule Rule(String phaseName, String currentImports)
           
 void setBaseURL(URL newURL)
           
 void setEncoding(String newEncoding)
           
 SinglePhaseTransducer SinglePhaseTransducer(String javaimportblock)
           
protected  ParseCpsl spawn(URL sptURL)
           
protected  Pair substituteTemplate(Token templateNameTok, Map<String,Object> values)
          Takes a string containing ${key} placeholders and substitutes in the corresponding values from the given map.
 Pair TemplateCall()
           
 void TemplateDef()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

macrosMap

protected HashMap macrosMap
A table of macro definitions.


templatesMap

protected HashMap templatesMap
A table of template definitions. Keys are template names, values are Pairs of token kind and value, as returned by AttrVal.


baseURL

protected URL baseURL

encoding

protected String encoding

curSPT

protected SinglePhaseTransducer curSPT

token_source

public ParseCpslTokenManager token_source

token

public Token token

jj_nt

public Token jj_nt

lookingAhead

public boolean lookingAhead
Constructor Detail

ParseCpsl

public ParseCpsl(URL url,
                 String encoding)
          throws IOException
Construct from a URL and an encoding

Throws:
IOException

ParseCpsl

public ParseCpsl(URL url,
                 String encoding,
                 HashMap existingMacros)
          throws IOException
Construct from a URL and an encoding

Throws:
IOException

ParseCpsl

public ParseCpsl(URL url,
                 String encoding,
                 HashMap existingMacros,
                 HashMap existingTemplates)
          throws IOException
Throws:
IOException

ParseCpsl

public ParseCpsl(Reader stream,
                 HashMap existingMacros)

ParseCpsl

public ParseCpsl(Reader stream,
                 HashMap existingMacros,
                 HashMap existingTemplates)

ParseCpsl

public ParseCpsl(InputStream stream)

ParseCpsl

public ParseCpsl(InputStream stream,
                 String encoding)

ParseCpsl

public ParseCpsl(Reader stream)

ParseCpsl

public ParseCpsl(ParseCpslTokenManager tm)
Method Detail

addStatusListener

public void addStatusListener(StatusListener listener)

removeStatusListener

public void removeStatusListener(StatusListener listener)

fireStatusChangedEvent

protected void fireStatusChangedEvent(String text)

createSinglePhaseTransducer

protected SinglePhaseTransducer createSinglePhaseTransducer(String name)

spawn

protected ParseCpsl spawn(URL sptURL)
                   throws IOException
Throws:
IOException

finishSPT

protected void finishSPT(SinglePhaseTransducer t)
                  throws ParseException
Throws:
ParseException

finishBPE

protected void finishBPE(BasicPatternElement bpe)

MultiPhaseTransducer

public MultiPhaseTransducer MultiPhaseTransducer()
                                          throws ParseException
Attempt to parse a multi phase transducer from the current file. This method ensures that the JAPE file reader is properly closed when the method completes, whether it completes successfully or throws an exception.

Throws:
ParseException

appendJavaStringLiteral

protected void appendJavaStringLiteral(StringBuffer buf,
                                       String str)
Append the given string to the end of the given buffer as a Java string literal. If str is null, we append the four characters n, u, l, l. Otherwise, we append the contents of str surrounded by double quotes, except that characters in str are escaped as necessary to be a legal Java string literal: backspace, formfeed, tab, newline and return are replaced by their escape sequences \b, \f, etc.; single and double quote and backslash are preceded by an extra backslash; other non-ASCII and non-printing characters are rendered as Unicode escapes (backslash-u followed by four hex digits).


appendAnnotationAdd

protected void appendAnnotationAdd(StringBuffer blockBuffer,
                                   String newAnnotType,
                                   String annotSetName)

substituteTemplate

protected Pair substituteTemplate(Token templateNameTok,
                                  Map<String,Object> values)
                           throws ParseException
Takes a string containing ${key} placeholders and substitutes in the corresponding values from the given map. If there is no value in the map for a particular placeholder it is left un-resolved, i.e. given a template of "${key1}/${key2}" and a values map of just [key1: "hello"], this method would return "hello/${key2}".

Throws:
ParseException

setBaseURL

public void setBaseURL(URL newURL)

setEncoding

public void setEncoding(String newEncoding)

_MultiPhaseTransducer

public final MultiPhaseTransducer _MultiPhaseTransducer()
                                                 throws ParseException
Throws:
ParseException

SinglePhaseTransducer

public final SinglePhaseTransducer SinglePhaseTransducer(String javaimportblock)
                                                  throws ParseException
Throws:
ParseException

JavaImportBlock

public final String JavaImportBlock()
                             throws ParseException
Throws:
ParseException

ControllerStartedBlock

public final String ControllerStartedBlock()
                                    throws ParseException
Throws:
ParseException

ControllerFinishedBlock

public final String ControllerFinishedBlock()
                                     throws ParseException
Throws:
ParseException

ControllerAbortedBlock

public final String ControllerAbortedBlock()
                                    throws ParseException
Throws:
ParseException

Rule

public final Rule Rule(String phaseName,
                       String currentImports)
                throws ParseException
Throws:
ParseException

MacroDef

public final void MacroDef()
                    throws ParseException
Throws:
ParseException

TemplateDef

public final void TemplateDef()
                       throws ParseException
Throws:
ParseException

LeftHandSide

public final LeftHandSide LeftHandSide()
                                throws ParseException
Throws:
ParseException

ConstraintGroup

public final void ConstraintGroup(LeftHandSide lhs,
                                  ConstraintGroup cg)
                           throws ParseException
Throws:
ParseException

PatternElement

public final PatternElement PatternElement(LeftHandSide lhs)
                                    throws ParseException
Throws:
ParseException

BasicPatternElement

public final BasicPatternElement BasicPatternElement()
                                              throws ParseException
Throws:
ParseException

ComplexPatternElement

public final ComplexPatternElement ComplexPatternElement(LeftHandSide lhs)
                                                  throws ParseException
Throws:
ParseException

KleeneOperator

public final KleeneOperator KleeneOperator()
                                    throws ParseException
Throws:
ParseException

Constraint

public final Constraint Constraint()
                            throws ParseException
Throws:
ParseException

FeatureAccessor

public final AnnotationAccessor FeatureAccessor()
                                         throws ParseException
Throws:
ParseException

AttrVal

public final Pair AttrVal()
                   throws ParseException
Throws:
ParseException

TemplateCall

public final Pair TemplateCall()
                        throws ParseException
Throws:
ParseException

RightHandSide

public final RightHandSide RightHandSide(String phaseName,
                                         String ruleName,
                                         LeftHandSide lhs,
                                         String imports)
                                  throws ParseException
Throws:
ParseException

Action

public final String[] Action(boolean checkLabel)
                      throws ParseException
Throws:
ParseException

NamedJavaBlock

public final String[] NamedJavaBlock(boolean checkLabel)
                              throws ParseException
Throws:
ParseException

AnonymousJavaBlock

public final String[] AnonymousJavaBlock()
                                  throws ParseException
Throws:
ParseException

AssignmentExpression

public final String[] AssignmentExpression(boolean checkLabel)
                                    throws ParseException
Throws:
ParseException

ReInit

public void ReInit(InputStream stream)

ReInit

public void ReInit(InputStream stream,
                   String encoding)

ReInit

public void ReInit(Reader stream)

ReInit

public void ReInit(ParseCpslTokenManager tm)

getNextToken

public final Token getNextToken()

getToken

public final Token getToken(int index)

generateParseException

public ParseException generateParseException()

enable_tracing

public final void enable_tracing()

disable_tracing

public final void disable_tracing()