Ejemplo n.º 1
0
 public CodeSetShift(INode predecessor, CodeSetType codeSet, HighModeChange highModeChange) : base(predecessor)
 {
     _codeSet        = codeSet;
     _highModeChange = highModeChange;
     FinalCodeSet    = predecessor.FinalCodeSet;
     Length          = 1;
     _highMode       = highModeChange.Instantiate();
 }
 private void Apply(Symbol symbol, CodeSetType type)
 {
     _current       = symbol;
     _activeType    = type;
     _tempSet       = null;
     _activeCodeSet = _mapping.GetCodeSet(_activeType);
     Consume();
 }
Ejemplo n.º 3
0
 public CodeSetStart(CodeSetType codeSet, int length, bool isTerminal, HighModeChange highModeChange)
 {
     _codeSet        = codeSet;
     _highModeChange = highModeChange;
     _highMode       = _highModeChange.Instantiate();
     Length          = length;
     IsTerminal      = isTerminal;
 }
Ejemplo n.º 4
0
 public CodeSetRun(INode predecessor, CodeSetType codeSet, int length, bool isTerminal,
                   HighModeChange highModeChange) : base(predecessor)
 {
     _highModeChange   = highModeChange;
     _needsChangeOfSet = predecessor.FinalCodeSet != codeSet;
     FinalCodeSet      = codeSet;
     Length            = length;
     IsTerminal        = isTerminal;
     _highMode         = highModeChange.Instantiate();
 }
        private void HandleShift(CodeSetType expectedCurrentSet, CodeSetType targetSet)
        {
            if (_tempSet.HasValue)
            {
                throw new CodeError("Already in a shifting state.");
            }

            if (_activeType != expectedCurrentSet)
            {
                throw new CodeError($"Cannot shift to {targetSet} from current code set {_activeType}");
            }

            _tempSet       = targetSet;
            _activeCodeSet = _mapping.GetCodeSet(_tempSet.Value);
            Consume();
        }
        private void HandleCodeSetSwitch(CodeSetType target)
        {
            if (_tempSet.HasValue)
            {
                throw new CodeError("Cannot switch code set after shift.");
            }

            if (_activeType == target)
            {
                throw new CodeError("Redundant code set switch.");
            }

            _activeType    = target;
            _activeCodeSet = _mapping.GetCodeSet(_activeType);
            Consume();
        }
Ejemplo n.º 7
0
        public ICodeSet GetCodeSet(CodeSetType type)
        {
            switch (type)
            {
            case CodeSetType.CodeA:
                return(CodeA);

            case CodeSetType.CodeB:
                return(CodeB);

            case CodeSetType.CodeC:
                return(CodeC);

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }
        }