cz.cuni.amis.pogamut.sposh.elements
Class PoshParser

Package class diagram package PoshParser
java.lang.Object
  extended by cz.cuni.amis.pogamut.sposh.elements.PoshParser
All Implemented Interfaces:
PoshParserConstants

public class PoshParser
extends Object
implements PoshParserConstants


Field Summary
 Token jj_nt
          Next token.
 Token token
          Current token.
 PoshParserTokenManager token_source
          Generated Token Manager.
 
Fields inherited from interface cz.cuni.amis.pogamut.sposh.elements.PoshParserConstants
AD, AP, COMMA, COMMENT, COMPETENCE, DC, DEFAULT, DOCUMENTATION, DRIVES, ELEMENTS, ENUM_VALUE, EOF, EQUAL_SIGN, ERROR_CHARS, FALSE, GOAL, HOURS, HZ, JAVA_IDENTIFIER, LBRACE, MINUTES, NAME, NIL, NONE, NUMFLOAT, NUMINT, PM, PREDICATE, RBRACE, SECONDS, SINGLE_LINE_COMMENT, tokenImage, TRIGGER, TRUE, VARIABLE, VARS
 
Constructor Summary
PoshParser(InputStream stream)
          Constructor with InputStream.
PoshParser(InputStream stream, String encoding)
          Constructor with InputStream and supplied encoding
PoshParser(PoshParserTokenManager tm)
          Constructor with generated Token Manager.
PoshParser(Reader stream)
          Constructor.
 
Method Summary
 ActionPattern actionPattern()
          action-pattern ::= AP NAME ( NIL | "("
 void actionPatternElements(ActionPattern ap, FormalParameters formalParameters)
          process actions of the AP and add them into the passed ap.
 Adopt adapt()
          adapt ::= AD NAME [ ] "(" "(" "(" ")"
 cz.cuni.amis.pogamut.sposh.elements.PoshParser.Packet<Arguments.Argument,Boolean> callParameter(int index, boolean named)
          Parameter used when calling C/AP/sense/action callParameter :: [ "=" ( | value() ) ]
 Arguments callParametersList(FormalParameters formalParameters)
          callParametersList:: callParameter() ( "," callParameter() )* ")"
 Competence competence()
          competence ::= C NAME ( NIL | "("
 CompetenceElement competenceElement(FormalParameters formalParameters)
          competence-element ::= "(" NAME [ "(" ] NAME [ INTNUM ] ")"
 List<Sense> competenceGoal(FormalParameters formalParameters)
          ( NIL | "(" | ) "(" ELEMENTS Part of competence() rule
 List<CompetenceElement> competencePriorities(FormalParameters formalParameters)
          competence-priorities ::= + competence-elements ::= "(" + ")" => competence-priorities ::= ( "(" + ")" )+.
 void disable_tracing()
          Disable tracing.
 void docString(PoshPlan plan)
          docstring ::= DOCUMENTATION COMMENT COMMENT COMMENT ")"
 void driveCollection(DriveCollection dc)
          Take passed drive collection and put the data (name, drives) into it.
 void driveCollectionGoal(DriveCollection dc, FormalParameters formalParameters)
          Process goal of DC (if exists).
 DriveElement driveElement(FormalParameters formalParameters)
          Create a drive and return it.
 cz.cuni.amis.pogamut.sposh.elements.PoshParser.Packet<Arguments,Freq> driveElementActionFreq(FormalParameters formalParameters)
          Nonterminal for possible arguments of the action call of the drive action and the frequency.
 Freq driveElementFreq()
          Get specified frequency.
 List<Sense> driveElementTrigger(FormalParameters formalParameters)
          Read trigger (list of senses) and return it.
 void enable_tracing()
          Enable tracing.
 Freq freq()
          freq ::= ")"
 Freq.FreqUnits freqUnit()
          freq-unit ::= HOURS | MINUTES | SECONDS | HZ | PM | NONE
 Sense fullSense(FormalParameters formalParameters)
          full-sense ::= "(" NAME [ []] ")"
 ParseException generateParseException()
          Generate ParseException.
 Token getNextToken()
          Get the next Token.
 Token getToken(int index)
          Get the specific Token.
 List<Sense> goal(FormalParameters formalParameters)
          Process goal sense and return them.
 String optComment()
          Optional comment, if no comment, return blank string.
 int optRetries()
          Optional number of retries.
 FormalParameters parameters()
          Declare parameters in C or AP.
 PoshPlan parsePlan()
          FIXME: According to official grammar, plan can consists only from single competence or action pattern.
 void planFirstElement(PoshPlan plan)
          [ "(" ] Part of plan rule.
 void planFirstHalf(PoshPlan plan)
          First half of plan rule.
 void planSecondHalf(PoshPlan plan)
          ( "(" | )* Part of plan() rule
 void planSecondHalfElements(PoshPlan plan)
          ( | ) planSecondHalf(plan)
 void ReInit(InputStream stream)
          Reinitialise.
 void ReInit(InputStream stream, String encoding)
          Reinitialise.
 void ReInit(PoshParserTokenManager tm)
          Reinitialise.
 void ReInit(Reader stream)
          Reinitialise.
 PrimitiveCall senseCall(FormalParameters formalParameters)
          SenseCall sense:: [ "(" callParametersList() ]
 void sensePredicate(cz.cuni.amis.pogamut.sposh.elements.SenseComponents _senseComp)
          predicate ::= PREDICATE
 List<Sense> senses(FormalParameters formalParameters)
          Get senses (if there are any) and return them.
 List<Sense> sensesList(FormalParameters formalParameters)
          ( NAME | )+ Part of sense() rule.
 Sense sensesListElement(FormalParameters formalParameters)
          NAME | Part of sensesList() rule XXX: I am using in first case, so it is impossible to have (sense1(sense2)) vs (sense1(simple_string)) because the calling vars are not compulsory, yet
 void senseValue(cz.cuni.amis.pogamut.sposh.elements.SenseComponents _senseComp)
          value ::= NUMINT | NUMFLOAT | NAME | ENUM_VALUE | NIL Part of full-sense parsing.
 SolTime time()
          time ::= ")"
 SolTime.TimeUnits timeUnit()
          time-unit ::= HOURS | MINUTES | SECONDS | NONE
 List<Sense> trigger(FormalParameters formalParameters)
          Get list of senses of a trigger.
 Object value()
           
 FormalParameters.Parameter varDeclaration()
          varDeclare:: "=" value()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

token_source

public PoshParserTokenManager token_source
Generated Token Manager.


token

public Token token
Current token.


jj_nt

public Token jj_nt
Next token.

Constructor Detail

PoshParser

public PoshParser(InputStream stream)
Constructor with InputStream.


PoshParser

public PoshParser(InputStream stream,
                  String encoding)
Constructor with InputStream and supplied encoding


PoshParser

public PoshParser(Reader stream)
Constructor.


PoshParser

public PoshParser(PoshParserTokenManager tm)
Constructor with generated Token Manager.

Method Detail

parsePlan

public final PoshPlan parsePlan()
                         throws ParseException
FIXME: According to official grammar, plan can consists only from single competence or action pattern. Sorry, but I don't allow this for now. plan ::= "(" [ "(" ] ( "(" | )* "(" ( "(" | )* ")"

Throws:
ParseException

planFirstElement

public final void planFirstElement(PoshPlan plan)
                            throws ParseException
[ "(" ] Part of plan rule.

Throws:
ParseException

planFirstHalf

public final void planFirstHalf(PoshPlan plan)
                         throws ParseException
First half of plan rule. ( "(" | )*

Throws:
ParseException

planSecondHalf

public final void planSecondHalf(PoshPlan plan)
                          throws ParseException
( "(" | )* Part of plan() rule

Throws:
ParseException

planSecondHalfElements

public final void planSecondHalfElements(PoshPlan plan)
                                  throws ParseException
( | ) planSecondHalf(plan)

Throws:
ParseException

docString

public final void docString(PoshPlan plan)
                     throws ParseException
docstring ::= DOCUMENTATION COMMENT COMMENT COMMENT ")"

Throws:
ParseException

driveCollection

public final void driveCollection(DriveCollection dc)
                           throws ParseException
Take passed drive collection and put the data (name, drives) into it.
 driveCollection() :: "DC"  [  ] "(" "drives" ( "(" + ")" )+ ")" ")"
 
XXX: It has extra braces around , remove them

Throws:
ParseException

driveCollectionGoal

public final void driveCollectionGoal(DriveCollection dc,
                                      FormalParameters formalParameters)
                               throws ParseException
Process goal of DC (if exists). ( NIL | "(" | ) "(" Part of driveCollection() rule.

Throws:
ParseException

goal

public final List<Sense> goal(FormalParameters formalParameters)
                       throws ParseException
Process goal sense and return them. goal ::= GOAL ")"

Throws:
ParseException

driveElement

public final DriveElement driveElement(FormalParameters formalParameters)
                                throws ParseException
Create a drive and return it.
 drive-element ::= "(" NAME ( NIL | "("  | ) NAME ( NIL | "("  | )  ")"
 

Throws:
ParseException

driveElementActionFreq

public final cz.cuni.amis.pogamut.sposh.elements.PoshParser.Packet<Arguments,Freq> driveElementActionFreq(FormalParameters formalParameters)
                                                                                                   throws ParseException
Nonterminal for possible arguments of the action call of the drive action and the frequency. driveElementActionFreq:: ( | "(" ( | ) | ) I should probably use lookahead of 2 or more, but I really need this fast for continuous syntax highlighting.

Throws:
ParseException

driveElementTrigger

public final List<Sense> driveElementTrigger(FormalParameters formalParameters)
                                      throws ParseException
Read trigger (list of senses) and return it.

( NIL | "(" | ) Part of driveElement rule

Throws:
ParseException

driveElementFreq

public final Freq driveElementFreq()
                            throws ParseException
Get specified frequency. If no frequency specified, return Freq.INFINITE. ( NIL | "(" | ) Part of driveElementRule

Throws:
ParseException

competence

public final Competence competence()
                            throws ParseException
competence ::= C NAME ( NIL | "("
Throws:
ParseException

parameters

public final FormalParameters parameters()
                                  throws ParseException
Declare parameters in C or AP. parameters:: "vars" "(" varDeclaration() ( "," varDeclaration() )* ")"

Throws:
ParseException

varDeclaration

public final FormalParameters.Parameter varDeclaration()
                                                throws ParseException
varDeclare:: "=" value()

Throws:
ParseException

competenceGoal

public final List<Sense> competenceGoal(FormalParameters formalParameters)
                                 throws ParseException
( NIL | "(" | ) "(" ELEMENTS Part of competence() rule

Throws:
ParseException

competencePriorities

public final List<CompetenceElement> competencePriorities(FormalParameters formalParameters)
                                                   throws ParseException
competence-priorities ::= + competence-elements ::= "(" + ")" => competence-priorities ::= ( "(" + ")" )+.

Throws:
ParseException

competenceElement

public final CompetenceElement competenceElement(FormalParameters formalParameters)
                                          throws ParseException
competence-element ::= "(" NAME [ "(" ] NAME [ INTNUM ] ")"

Throws:
ParseException

optRetries

public final int optRetries()
                     throws ParseException
Optional number of retries. If missing, return CompetenceElement.INFINITE_RETRIES.

Throws:
ParseException

optComment

public final String optComment()
                        throws ParseException
Optional comment, if no comment, return blank string. opt-comment ::= COMMENT |

Returns:
Comment or if comment is missing, blank string.
Throws:
ParseException

actionPattern

public final ActionPattern actionPattern()
                                  throws ParseException
action-pattern ::= AP NAME ( NIL | "("
Throws:
ParseException

adapt

public final Adopt adapt()
                  throws ParseException
adapt ::= AD NAME [ ] "(" "(" "(" ")"

Throws:
ParseException

actionPatternElements

public final void actionPatternElements(ActionPattern ap,
                                        FormalParameters formalParameters)
                                 throws ParseException
process actions of the AP and add them into the passed ap. action-pattern-elements ::= ( | NAME )+ ")" FIXME: full-sense is not implemented here, because I have no idea what to do with it. I have't even seen it used anywhere so it is doable for now.

Throws:
ParseException

time

public final SolTime time()
                   throws ParseException
time ::= ")"

Throws:
ParseException

timeUnit

public final SolTime.TimeUnits timeUnit()
                                 throws ParseException
time-unit ::= HOURS | MINUTES | SECONDS | NONE

Throws:
ParseException

freq

public final Freq freq()
                throws ParseException
freq ::= ")"

Throws:
ParseException

freqUnit

public final Freq.FreqUnits freqUnit()
                              throws ParseException
freq-unit ::= HOURS | MINUTES | SECONDS | HZ | PM | NONE

Throws:
ParseException

trigger

public final List<Sense> trigger(FormalParameters formalParameters)
                          throws ParseException
Get list of senses of a trigger. trigger ::= ")"

Throws:
ParseException

senses

public final List<Sense> senses(FormalParameters formalParameters)
                         throws ParseException
Get senses (if there are any) and return them. senses ::= ( NIL | "(" ( NAME | )+ ")" )

Throws:
ParseException

sensesList

public final List<Sense> sensesList(FormalParameters formalParameters)
                             throws ParseException
( NAME | )+ Part of sense() rule.

Throws:
ParseException

sensesListElement

public final Sense sensesListElement(FormalParameters formalParameters)
                              throws ParseException
NAME | Part of sensesList() rule XXX: I am using in first case, so it is impossible to have (sense1(sense2)) vs (sense1(simple_string)) because the calling vars are not compulsory, yet

Throws:
ParseException

fullSense

public final Sense fullSense(FormalParameters formalParameters)
                      throws ParseException
full-sense ::= "(" NAME [ []] ")"

Throws:
ParseException

senseCall

public final PrimitiveCall senseCall(FormalParameters formalParameters)
                              throws ParseException
SenseCall sense:: [ "(" callParametersList() ]

Throws:
ParseException

callParametersList

public final Arguments callParametersList(FormalParameters formalParameters)
                                   throws ParseException
callParametersList:: callParameter() ( "," callParameter() )* ")"

Throws:
ParseException

callParameter

public final cz.cuni.amis.pogamut.sposh.elements.PoshParser.Packet<Arguments.Argument,Boolean> callParameter(int index,
                                                                                                             boolean named)
                                                                                                      throws ParseException
Parameter used when calling C/AP/sense/action callParameter :: [ "=" ( | value() ) ]

Parameters:
named - was at least one named call parameter specified in the list before this one?
Throws:
ParseException

senseValue

public final void senseValue(cz.cuni.amis.pogamut.sposh.elements.SenseComponents _senseComp)
                      throws ParseException
value ::= NUMINT | NUMFLOAT | NAME | ENUM_VALUE | NIL Part of full-sense parsing.

Throws:
ParseException

sensePredicate

public final void sensePredicate(cz.cuni.amis.pogamut.sposh.elements.SenseComponents _senseComp)
                          throws ParseException
predicate ::= PREDICATE

Throws:
ParseException

value

public final Object value()
                   throws ParseException
Throws:
ParseException

ReInit

public void ReInit(InputStream stream)
Reinitialise.


ReInit

public void ReInit(InputStream stream,
                   String encoding)
Reinitialise.


ReInit

public void ReInit(Reader stream)
Reinitialise.


ReInit

public void ReInit(PoshParserTokenManager tm)
Reinitialise.


getNextToken

public final Token getNextToken()
Get the next Token.


getToken

public final Token getToken(int index)
Get the specific Token.


generateParseException

public ParseException generateParseException()
Generate ParseException.


enable_tracing

public final void enable_tracing()
Enable tracing.


disable_tracing

public final void disable_tracing()
Disable tracing.



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