Class Parser


  • public class Parser
    extends LexicalAnalyser
    Simple recursive decent parser for the communication protocol. Used by the EngineStub.
    • Constructor Detail

      • Parser

        public Parser​(java.io.InputStream in)
        Constructor
        Parameters:
        in - - The input stream
    • Method Detail

      • parseProlog

        public void parseProlog()
                         throws EngineException,
                                java.io.IOException
        Parses the prolog
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseId

        public java.lang.String parseId()
                                 throws ProtocolException,
                                        java.io.IOException
        Parses and gets the string.
        Returns:
        The response string
        Throws:
        ProtocolException - broken engine communication protocol
        java.io.IOException - engine crash or problem in communication.
      • parseInteger

        public int parseInteger()
                         throws ProtocolException,
                                java.io.IOException,
                                ServerException
        Parses and get the integer value
        Returns:
        The integer value of characters
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
        ServerException - engine returned an error
      • parseLong

        public long parseLong()
                       throws ProtocolException,
                              java.io.IOException,
                              ServerException
        Parses the response string in 'long'
        Returns:
        The value in 'long' of the string
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
        ServerException - engine returned an error
      • parseBigDecimal

        public java.math.BigDecimal parseBigDecimal()
                                             throws ProtocolException,
                                                    java.io.IOException
        Parse the float of the next token
        Returns:
        The float value
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
      • parseLimit

        public Limit parseLimit()
                         throws ProtocolException,
                                java.io.IOException,
                                ServerException
        Parses the limit : limit consists of a value and information about whether the limit is strict or not.
        Returns:
        The limit object
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
        ServerException - engine returned an error
      • parseEnd

        public void parseEnd()
                      throws ProtocolException,
                             java.io.IOException
        Parses the end of the characters.
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
      • parsePartialEnd

        public void parsePartialEnd()
                             throws ProtocolException,
                                    java.io.IOException
        Parses the partial end of the characters
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
      • parseSymbolicState

        public SymbolicState parseSymbolicState​(UppaalSystem system)
                                         throws ProtocolException,
                                                java.io.IOException,
                                                ServerException
        Parses the symbolic state in the system
        Parameters:
        system - - The uppaal system
        Returns:
        The new symbolic state in the system
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
        ServerException - engine returned an error
      • getErrorContext

        public java.lang.String getErrorContext​(java.lang.String errorLocation,
                                                int errorStartLine,
                                                int errorEndLine)
        Get the location string from the declaration text where the error happened
        Parameters:
        errorLocation - - The all error location text
        errorStartLine - - The start line number where the error string starts from
        errorEndLine - - The end line number where the error string ends to
        Returns:
        location - The error location
      • parseAcknowledgement

        public void parseAcknowledgement()
                                  throws EngineException,
                                         java.io.IOException
        Parses the prolog and the end of the characters
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseBlock

        public java.lang.String parseBlock()
                                    throws EngineException,
                                           java.io.IOException
        Read the context of the block
        Returns:
        The string
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseGanttHeader

        public void parseGanttHeader​(UppaalSystem system)
                              throws ProtocolException,
                                     EngineException,
                                     java.io.IOException
        Parses the header of the ganttchard
        Parameters:
        system - - The uppaal system
        Throws:
        ProtocolException - broken engine communication protocol.
        java.io.IOException - engine crash or problem in communication.
        EngineException - engine returned an error
      • parseSystem

        public UppaalSystem parseSystem​(Document document)
                                 throws EngineException,
                                        java.io.IOException
        Parses the uppaal system: - get the list of variables - get the list of clocks - add the processes into the system - add Gantt Chart parsing
        Parameters:
        document - - The document
        Returns:
        system - The uppaal system
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseLscProcess

        public LscProcess parseLscProcess​(Document document)
                                   throws EngineException,
                                          java.io.IOException
        Parse LSC process
        Parameters:
        document - - The model document
        Returns:
        null
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseProblems

        public java.util.ArrayList<Problem> parseProblems()
                                                   throws EngineException,
                                                          java.io.IOException
        Parses problems in the system
        Returns:
        The list of the problems
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseProblems

        public void parseProblems​(java.util.ArrayList<Problem> problems)
                           throws EngineException,
                                  java.io.IOException
        Parses problems in the system
        Parameters:
        problems - - Problems of the system
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • skipProblems

        public boolean skipProblems()
                             throws EngineException,
                                    java.io.IOException
        To skip problems
        Returns:
        True - Do it
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • problem

        public Problem problem()
                        throws EngineException,
                               java.io.IOException
        Create the problem
        Returns:
        The new problem
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseQueryResult

        public char parseQueryResult()
                              throws EngineException,
                                     java.io.IOException
        Parses query and get the query result
        Returns:
        The query ID
        Throws:
        java.io.IOException - engine crash or problem in communication.
        EngineException - problem in the Uppaal engine.
      • parseXTRTrace

        public SymbolicTrace parseXTRTrace​(UppaalSystem system)
                                    throws ProtocolException,
                                           java.io.IOException
        Parses the Trace
        Parameters:
        system - - The uppaal system
        Returns:
        trace - The list of the symbolic transition.
        Throws:
        java.io.IOException - engine crash or problem in communication.
        ProtocolException - broken engine communication protocol.
      • parseConcreteState

        public ConcreteState parseConcreteState​(UppaalSystem system)
                                         throws java.io.IOException,
                                                ProtocolException,
                                                ServerException
        Create the concrete state in the system: - Get the list of locations in the system - Get the list of variables of the system - Get the invariant value <l-len> <location>* <v-len> ( <value> <rate> )* <limit> <strict>
        Parameters:
        system - - The uppaal system
        Returns:
        The concrete state in the system
        Throws:
        java.io.IOException - engine crash or problem in communication.
        ProtocolException - broken engine communication protocol.
        ServerException - engine returned an error.
      • parseEnabledConcreteTransitions

        public java.util.ArrayList<ConcreteTransition> parseEnabledConcreteTransitions​(UppaalSystem system)
                                                                                throws EngineException,
                                                                                       java.io.IOException,
                                                                                       CannotEvaluateException
        Parses the limit of the concrete transition and collect the enabled concrete transition into the list
        Parameters:
        system - - The uppaal system
        Returns:
        succs - The enabled transition
        Throws:
        java.io.IOException - I/O communication error.
        EngineException - error in the server protocol.
        CannotEvaluateException - some expression could not be evaluated.
      • parseGanttChart

        public GanttChart parseGanttChart​(UppaalSystem system,
                                          java.math.BigDecimal globalTime)
                                   throws ProtocolException,
                                          ServerException,
                                          java.io.IOException
        Parses a Gantt chart. <num> (<identifier> <value> <value> <strict> <value> <strict>)* <num> a positive integer: Number of messages in the following <identifier> the row number/id <value> the value of the bar to be displayed. This number can be positive, 0 or negative. <value> a positive number: interval start time <strict> start of interval open or closed? <value> a positive number: interval stop time <strict> end of interval open or closed?
        Parameters:
        system - - The uppaal system
        globalTime - - The global time
        Returns:
        The ganttChart
        Throws:
        java.io.IOException - engine crash or problem in communication.
        ProtocolException - broken engine communication protocol.
        ServerException - engine returned an error.