cz.cuni.amis.pogamut.ut3.communication.messages.gbinfomessages
Class Yylex

Package class diagram package Yylex
java.lang.Object
  extended by cz.cuni.amis.pogamut.ut3.communication.messages.gbinfomessages.Yylex
All Implemented Interfaces:
IYylex, IUT2004Yylex

public class Yylex
extends Object
implements IUT2004Yylex

This class is a scanner generated by JFlex 1.4.3 on 5/19/14 4:43 AM from the specification file /mnt/jenkins/var/lib/jenkins/jobs/PogamutUT3 (deploy site)/workspace/src/main/jflex/GB3Parser.jflex


Field Summary
protected  Object actObj
           
static String DELIMITERS_EXTENDED
           
static String DELIMITERS_STANDARD
           
protected  ItemTranslator itemTranslator
          object that is used to translate messages into objects
protected  ItemTypeTranslator itemTypeTranslator
          object that is used to translate strings into item types
protected  Map<Integer,Double> mapIntDouble
          Map for list of String, Double
protected  Map<Integer,Double> mapIntIDDouble
          Map for list of String, Double
static int MSG_ALIVE
           
static int MSG_BEG
          lexical states
static int MSG_EMP
           
protected  IYylexObserver observer
          observer for the yylex for reporting exceptions
protected  UnrealIdTranslator translator
          parser reference, this parser will be used for translation of UnrealID to IntID
static int UNPROCESSED_MESSAGE
           
protected  double ut2004Time
          time in the UT2004
static int YYEOF
          This character denotes the end of file
static int YYINITIAL
           
 
Constructor Summary
Yylex()
           
Yylex(InputStream in)
          Creates a new scanner.
Yylex(Reader in)
          Creates a new scanner There is also a java.io.InputStream version of this constructor.
 
Method Summary
protected  boolean booleanValue(String txt)
          Return a boolean from boolean token in txt.
protected  ItemType.Category categoryValue(String txt)
          Return a Category of the item.
 void close()
           
protected  double doubleValue(String txt)
          Return a double from num token in txt.
protected  void exceptionOccured(Exception e, String info)
          Logs the exception if observer present, or print it to System.out.
protected  float floatValue(String txt)
          Return a float from num token in txt.
protected  String getToken(String text, int num)
          Returns 'num'-th token from 'text' using DELIMITERS_STANDARD.
protected  String getToken(String text, String delimiters, int num)
          Returns 'num'-th token from 'text' using 'delimiters'.
protected  double[] getTriple(String txt)
          Return a triple (double[]{x,y,z}) starting from num token(tokens are separated by space) in 'txt'
protected  Integer integerValue(String txt)
          Return an integer from num token in txt.
protected  int intValue(String txt)
          Return an integer from num token in txt.
protected  ItemDescriptor itemDescriptorValue(ItemType type)
           
protected  ItemType itemTypeValue(String txt)
          Return an ItemType instance.
protected  Location locationValue(String txt)
          Return a Location instance starting from num token(tokens are separated by space) in txt
protected  long longValue(String txt)
          Return a long from num token in txt.
static void main(String[] argv)
          Runs the scanner on input files.
protected  javax.vecmath.Point3d point3dValue(String txt)
          Return a Point3d instance starting from num token(tokens are separated by space) in txt
protected  Rotation rotationValue(String txt)
          Return a Rotation instance starting from num token(tokens are separated by space) in txt
 void setItemTranslator(ItemTranslator translator)
           
 void setItemTypeTranslator(ItemTypeTranslator translator)
           
 void setObserver(IYylexObserver observer)
           
protected
<T> void
setPropertyByReflection(Object object, String propertyName, Class<T> valueType, T value)
          Set property of an object by reflection Setter method name is expected to follow name convention "set", where the first letter of property name is upper case.
 void setReader(Reader reader)
           
 void setTeamId(ITeamId teamId)
          Sets teamId that has to be slipped to every IWorldObjectUpdatedEvent.
 void setTime(IWorldEvent obj, double time)
           
 void setTime(IWorldObjectUpdatedEvent obj, double time)
           
 void setTranslator(UnrealIdTranslator translator)
          Set parser translating UnrealID to IntID.
protected  cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId stringIdValue(String txt)
          Returns UnrealId for parsed token.
protected  String stringValue(String txt)
          Returns string for parsed token.
protected  InfoMessage tryParsingUnprocessedMessage(String messageName)
          This method should be overriden to parse additional messages, that are not part of PogamutUDK Core.
protected  boolean tryParsingUnprocessedMessageParameter(String paramName, String wholeParamText)
          This method should be overridden to parse parameters of additional messages that are not part of PogamuUDK Core.
protected  cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId unrealIdValue(String txt)
          Return an UnrealId instance from identificator token in txt.
protected  javax.vecmath.Vector3d vector3dValue(String txt)
          Return a Vector3d instance starting from num token(tokens are separated by space) in txt
protected  Velocity velocityValue(String txt)
          Return a Velocity instance starting from num token(tokens are separated by space) in txt
protected  void warning(String info)
          Send the warning to observer or prints it to the console.
protected  cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId worldObjectIdValue(String txt)
          Return an UnrealId instance from identificator token in txt.
 void yybegin(int newState)
          Enters a new lexical state
 char yycharat(int pos)
          Returns the character at position pos from the matched text.
 void yyclose()
          Closes the input stream.
 int yylength()
          Returns the length of the matched text region.
 InfoMessage yylex()
          Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.
 void yypushback(int number)
          Pushes the specified amount of characters back into the input stream.
 void yyreset(Reader reader)
          Resets the scanner to read from a new input stream.
 int yystate()
          Returns the current lexical state.
 String yytext()
          Returns the text matched by the current regular expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

YYEOF

public static final int YYEOF
This character denotes the end of file

See Also:
Constant Field Values

MSG_BEG

public static final int MSG_BEG
lexical states

See Also:
Constant Field Values

UNPROCESSED_MESSAGE

public static final int UNPROCESSED_MESSAGE
See Also:
Constant Field Values

YYINITIAL

public static final int YYINITIAL
See Also:
Constant Field Values

MSG_ALIVE

public static final int MSG_ALIVE
See Also:
Constant Field Values

MSG_EMP

public static final int MSG_EMP
See Also:
Constant Field Values

DELIMITERS_STANDARD

public static final String DELIMITERS_STANDARD
See Also:
Constant Field Values

DELIMITERS_EXTENDED

public static final String DELIMITERS_EXTENDED
See Also:
Constant Field Values

mapIntIDDouble

protected Map<Integer,Double> mapIntIDDouble
Map for list of String, Double


mapIntDouble

protected Map<Integer,Double> mapIntDouble
Map for list of String, Double


translator

protected UnrealIdTranslator translator
parser reference, this parser will be used for translation of UnrealID to IntID


itemTranslator

protected ItemTranslator itemTranslator
object that is used to translate messages into objects


observer

protected IYylexObserver observer
observer for the yylex for reporting exceptions


itemTypeTranslator

protected ItemTypeTranslator itemTypeTranslator
object that is used to translate strings into item types


ut2004Time

protected double ut2004Time
time in the UT2004


actObj

protected Object actObj
Constructor Detail

Yylex

public Yylex()

Yylex

public Yylex(Reader in)
Creates a new scanner There is also a java.io.InputStream version of this constructor.

Parameters:
in - the java.io.Reader to read input from.

Yylex

public Yylex(InputStream in)
Creates a new scanner. There is also java.io.Reader version of this constructor.

Parameters:
in - the java.io.Inputstream to read input from.
Method Detail

setReader

public void setReader(Reader reader)
Specified by:
setReader in interface IYylex

close

public void close()
           throws IOException
Specified by:
close in interface IYylex
Throws:
IOException

setItemTranslator

public void setItemTranslator(ItemTranslator translator)
Specified by:
setItemTranslator in interface IUT2004Yylex

setItemTypeTranslator

public void setItemTypeTranslator(ItemTypeTranslator translator)
Specified by:
setItemTypeTranslator in interface IUT2004Yylex

setObserver

public void setObserver(IYylexObserver observer)
Specified by:
setObserver in interface IYylex

setTranslator

public void setTranslator(UnrealIdTranslator translator)
Set parser translating UnrealID to IntID. This function should be called after constructor, I dont know how to define constructor, so this will do.

Specified by:
setTranslator in interface IUT2004Yylex

setTime

public void setTime(IWorldObjectUpdatedEvent obj,
                    double time)

setTime

public void setTime(IWorldEvent obj,
                    double time)

setPropertyByReflection

protected <T> void setPropertyByReflection(Object object,
                                           String propertyName,
                                           Class<T> valueType,
                                           T value)
Set property of an object by reflection Setter method name is expected to follow name convention "set", where the first letter of property name is upper case. Potential access restriction of the setter method is overriden via reflection.

Parameters:
object - the object
propertyName - property name
valueType - property value / setter argument type
value - value to set

exceptionOccured

protected void exceptionOccured(Exception e,
                                String info)
Logs the exception if observer present, or print it to System.out.

Does not throw the exception...

If exception 'e' is null, only info message is written to logs.

Parameters:
e -
info -

warning

protected void warning(String info)
Send the warning to observer or prints it to the console.


tryParsingUnprocessedMessage

protected InfoMessage tryParsingUnprocessedMessage(String messageName)
This method should be overriden to parse additional messages, that are not part of PogamutUDK Core. This method is called whenever the parser meets a message name it does not recognize. If the message is recognized by overriding class, it should return new instance of a message the name represents. Otherwise it should return null. The newly created message is then accesible for parameter setting via #getParsedObject() . For further discussion on how this is done see wiki article.

Parameters:
messageName -
Returns:
New message or null if not recognized
See Also:
tryParsingUnprocessedMessageParameter(java.lang.String, java.lang.String)

tryParsingUnprocessedMessageParameter

protected boolean tryParsingUnprocessedMessageParameter(String paramName,
                                                        String wholeParamText)
This method should be overridden to parse parameters of additional messages that are not part of PogamuUDK Core. Once the message was recognized by tryParsingUnprocessedMessage(java.lang.String) this method is called for every parameter.

Parameters:
paramName - The name of the parameter as appeared in the Gamebots message
wholeParamText - Whole text of the parameter part of message (contains the param name) - this string can be directly passed to xxxValue methods of this class to obtain translated values for basically all usable datatypes. If this is not enough, use getToken(java.lang.String, int) to extract desired part of the message text (the value has index 1)
Returns:
See Also:
tryParsingUnprocessedMessage(java.lang.String)

getToken

protected String getToken(String text,
                          String delimiters,
                          int num)
Returns 'num'-th token from 'text' using 'delimiters'.

Use only IFF you're getting only one token from 'text'.

Parameters:
text -
delimiters -
Returns:
String token

getToken

protected String getToken(String text,
                          int num)
Returns 'num'-th token from 'text' using DELIMITERS_STANDARD.

Use only IFF you're getting only one token from 'text'.

Parameters:
text -
Returns:
String token

intValue

protected int intValue(String txt)
Return an integer from num token in txt.

Integer token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
Integer from given token.

longValue

protected long longValue(String txt)
Return a long from num token in txt.

Long token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
Integer from given token.

integerValue

protected Integer integerValue(String txt)
Return an integer from num token in txt.

Integer token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
Integer from given token.

doubleValue

protected double doubleValue(String txt)
Return a double from num token in txt.

Num token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
Double from given token.

floatValue

protected float floatValue(String txt)
Return a float from num token in txt.

Num token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
Float from given token.

getTriple

protected double[] getTriple(String txt)
Return a triple (double[]{x,y,z}) starting from num token(tokens are separated by space) in 'txt'

Parameters:
txt - text of parameter
Returns:
Array of three doubles from given token.

locationValue

protected Location locationValue(String txt)
Return a Location instance starting from num token(tokens are separated by space) in txt

Parameters:
txt - text of parameter
Returns:
Location from given token.

itemTypeValue

protected ItemType itemTypeValue(String txt)
Return an ItemType instance.

Parameters:
txt - text of parameter
Returns:
ItemType from given token.

itemDescriptorValue

protected ItemDescriptor itemDescriptorValue(ItemType type)

categoryValue

protected ItemType.Category categoryValue(String txt)
Return a Category of the item.

Parameters:
txt - text of parameter
Returns:
ItemType.Category from given token.

velocityValue

protected Velocity velocityValue(String txt)
Return a Velocity instance starting from num token(tokens are separated by space) in txt

Parameters:
txt - text of parameter
Returns:
Velocity from given token.

rotationValue

protected Rotation rotationValue(String txt)
Return a Rotation instance starting from num token(tokens are separated by space) in txt

Parameters:
txt - text of parameter
Returns:
Rotation from given token.

point3dValue

protected javax.vecmath.Point3d point3dValue(String txt)
Return a Point3d instance starting from num token(tokens are separated by space) in txt

Parameters:
txt - text of parameter
Returns:
Point3d from given token.

vector3dValue

protected javax.vecmath.Vector3d vector3dValue(String txt)
Return a Vector3d instance starting from num token(tokens are separated by space) in txt

Parameters:
txt - text of parameter
Returns:
Vector3d from given token.

stringValue

protected String stringValue(String txt)
Returns string for parsed token.

Parameters:
txt - text of parameter
Returns:
String from given token.

stringIdValue

protected cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId stringIdValue(String txt)
Returns UnrealId for parsed token.

Parameters:
txt - text of parameter
Returns:
StringId from given token.

booleanValue

protected boolean booleanValue(String txt)
Return a boolean from boolean token in txt.

Boolean token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
Boolean from given token.

unrealIdValue

protected cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId unrealIdValue(String txt)
Return an UnrealId instance from identificator token in txt.

Boolean token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
UnrealId from given token.

worldObjectIdValue

protected cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId worldObjectIdValue(String txt)
Return an UnrealId instance from identificator token in txt.

Boolean token is expected to be 'second token' in the 'txt' using delimiters " {}".

Parameters:
txt - text of parameter
Returns:
UnrealId from given token.

setTeamId

public void setTeamId(ITeamId teamId)
Sets teamId that has to be slipped to every IWorldObjectUpdatedEvent.

Specified by:
setTeamId in interface IUT2004Yylex

yyclose

public final void yyclose()
                   throws IOException
Closes the input stream.

Throws:
IOException

yyreset

public final void yyreset(Reader reader)
Resets the scanner to read from a new input stream. Does not close the old reader. All internal variables are reset, the old input stream cannot be reused (internal buffer is discarded and lost). Lexical state is set to ZZ_INITIAL.

Parameters:
reader - the new input stream

yystate

public final int yystate()
Returns the current lexical state.


yybegin

public final void yybegin(int newState)
Enters a new lexical state

Parameters:
newState - the new lexical state

yytext

public final String yytext()
Returns the text matched by the current regular expression.


yycharat

public final char yycharat(int pos)
Returns the character at position pos from the matched text. It is equivalent to yytext().charAt(pos), but faster

Parameters:
pos - the position of the character to fetch. A value from 0 to yylength()-1.
Returns:
the character at position pos

yylength

public final int yylength()
Returns the length of the matched text region.


yypushback

public void yypushback(int number)
Pushes the specified amount of characters back into the input stream. They will be read again by then next call of the scanning method

Parameters:
number - the number of characters to be read again. This number must not be greater than yylength()!

yylex

public InfoMessage yylex()
                  throws IOException
Resumes scanning until the next regular expression is matched, the end of input is encountered or an I/O-Error occurs.

Specified by:
yylex in interface IYylex
Returns:
the next token
Throws:
IOException - if any I/O-Error occurs

main

public static void main(String[] argv)
Runs the scanner on input files. This is a standalone scanner, it will print any unmatched text to System.out unchanged.

Parameters:
argv - the command line, contains the filenames to run the scanner on.


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.