Ejemplo n.º 1
0
        /// <summary>
        /// Converts the given line into a interpreted token and processes it into the yang tree at the current state.
        /// </summary>
        /// <param name="InputBlock">The given row of the yang file</param>
        /// <param name="MultilineBeginingWasPresent">Determines wether the given row is a part of a Multiline token</param>
        /// <param name="PreviousState">The previous state of the interpreter which is the state after the previously processed row.</param>
        /// <returns></returns>
        internal string ConvertLine(string InputBlock, ref bool MultilineBeginingWasPresent, ref TokenTypes PreviousState)
        {
            CurrentRow = InputBlock;
            var TokenForCurrentRow = TokenCreator.GetTokenForRow(InputBlock, PreviousToken);

            if (TokenForCurrentRow != null)
            {
                if (TokenForCurrentRow.TokenTypeSpecialInfo == TokenTypes.ValueForPreviousLineBeg)
                {
                    MultilineBeginingWasPresent = true;
                }

                if (IsMultiLineToken(TokenForCurrentRow))
                {
                    return(HandleMultilineToken(TokenForCurrentRow, ref PreviousState));
                }

                else if (PreviousToken != null)
                {
                    TokenForCurrentRow          = MergeMultilineEndingToken(TokenForCurrentRow, PreviousState, MultilineBeginingWasPresent);
                    MultilineBeginingWasPresent = false;
                }
                ProcessToken(TokenForCurrentRow);
                PreviousState = TokenTypes.Start;
            }
            else
            {
                TokenCreationFail(LineNumber);
            }
            return(TokenForCurrentRow.InnerBlock);
        }
Ejemplo n.º 2
0
        internal Interpreter(InterpreterOption opt = InterpreterOption.Normal)
        {
            SubStatementAllowanceCollection.Init();

            Option = opt;
            InterpreterStatusStack.Push(typeof(Interpreter));
            TokenCreator.Init();
        }