Uploaded image for project: 'Daffodil'
  1. Daffodil
  2. DFDL-1437

Clarity: DFA Rules - eliminate anonymous classes and functions

XMLWordPrintableJSON

    • Icon: Improvement Improvement
    • Resolution: Unresolved
    • Icon: Normal Normal
    • deferred
    • None
    • Back End, clean ups
    • None

      This is a lisp sort of thing to do as written, but there really is no reason these can't be ordinary objects with two methods, test and act. The code would be clearer and easier to debug. Particularly if the classes have names like

      final class StartState(states: => ArrayBuffer[State], val stateNum: Int) extends State(states) {
         type R = Registers // put into State base class, protected
       
         object Got_EC_goto_ESCState extends Rule {
             def test(r: R) = { ... }
             def act(r: R) = { ... }
           }
       
        object Got_EEC_goto_ESCESCState extends Rule {
             def test(r: R) = { ... }
             def act(r: R) = { ... }
           }
      ...
        override val rules = ArrayBuffer(
           Got_EC_goto_ESCState, 
           Got_EEC_goto_EECState,
          ...
        )
      ...
      }

      In the above, the nesting makes it clear each "Rule" which is a state-machine transition, originates at a particular state.

              Unassigned Unassigned
              mbeckerle.dfdl Mike Beckerle
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: