Package net.sf.smc

Class SmcSyntaxChecker


  • public final class SmcSyntaxChecker
    extends SmcVisitor
    Performs a global syntax check on the various elements of the abstract syntax tree. This includes:
    • Verifying that a start state has been specified and that the state exists.
    • If this is C++ code generation that a header file is specified
    • If this is Java code generation that the .sm fle and the context class have the same name.
      (Note: Removed as of v. 6.1.0 due to addition of %fsmclass feature).
    • If this is TCL code generation that argument parameter types are eith value or reerence.
    • That if a transition is defined multiple times within the same state that each transition definition has a unique guard.
    • That transition end states are valid states (the state exists and is not the Default state).
    Author:
    Charles Rapp
    See Also:
    SmcElement
    • Constructor Detail

      • SmcSyntaxChecker

        public SmcSyntaxChecker​(String fsm,
                                TargetLanguage targetLanguage)
        Creates a syntax checker for the named FSM and target programming language.
        Parameters:
        fsm - the finite state machine's name.
        targetLanguage - the target programming language.
    • Method Detail

      • isValid

        public boolean isValid()
        Returns true if no errors were found and false if there are syntax errors.
        Returns:
        true if no errors were found and false if there are syntax errors.
      • getMessages

        public List<SmcMessage> getMessages()
        Returns a list of warning and error messages.
        Returns:
        a list of warning and error messages.
      • visit

        public void visit​(SmcFSM fsm)
        Verifies that the context class and source files exist.
        Overrides:
        visit in class SmcVisitor
        Parameters:
        fsm - verify this FSM instance.
      • visit

        public void visit​(SmcMap map)
        Checks the map's states.
        Overrides:
        visit in class SmcVisitor
        Parameters:
        map - verify this FSM map.
      • visit

        public void visit​(SmcState state)
        Checks if the state's transitions contain valid end states.
        Overrides:
        visit in class SmcVisitor
        Parameters:
        state - verify this FSM state.
      • visit

        public void visit​(SmcTransition transition)
        Checks the transition guards.
        Overrides:
        visit in class SmcVisitor
        Parameters:
        transition - check this FSM transition.
      • visit

        public void visit​(SmcGuard guard)
        Checks if the guard has a valid end state.
        Overrides:
        visit in class SmcVisitor
        Parameters:
        guard - verify this FSM guard.
      • visit

        public void visit​(SmcParameter parameter)
        Checks if the parameter types are acceptable.
        Overrides:
        visit in class SmcVisitor
        Parameters:
        parameter - verify this FSM parameter.