Exemplo n.º 1
0
        private SuperLinkedList <WordInfo> GetInitSegment(string text)
        {
            SuperLinkedList <WordInfo> result = new SuperLinkedList <WordInfo>();

            var lexical = new Lexical(text);

            DFAResult dfaResult;

            for (int i = 0; i < text.Length; i++)
            {
                char c = text[i];

                dfaResult = lexical.Input(c, i);

                switch (dfaResult)
                {
                case DFAResult.Continue:
                    continue;

                case DFAResult.Quit:
                    result.AddLast(lexical.OutputToken);
                    break;

                case DFAResult.ElseQuit:
                    result.AddLast(lexical.OutputToken);
                    if (lexical.OldState != 255)
                    {
                        i--;
                    }

                    break;
                }
            }

            dfaResult = lexical.Input(0, text.Length);

            switch (dfaResult)
            {
            case DFAResult.Continue:
                break;

            case DFAResult.Quit:
                result.AddLast(lexical.OutputToken);
                break;

            case DFAResult.ElseQuit:
                result.AddLast(lexical.OutputToken);
                break;
            }

            return(result);
        }
Exemplo n.º 2
0
        public SyntaxAnalyse(string text)
        {
            _SFQLSentenceList = new List <TSFQLSentence>();

            Lexical lexical = new Lexical(text);

            DFAResult dfaResult;

            for (int i = 0; i < text.Length; i++)
            {
                dfaResult = lexical.Input(text[i], i);

                switch (dfaResult)
                {
                case DFAResult.Continue:
                    continue;

                case DFAResult.Quit:
                    InputLexicalToken(lexical.OutputToken);
                    break;

                case DFAResult.ElseQuit:
                    InputLexicalToken(lexical.OutputToken);
                    i--;
                    break;
                }
            }


            dfaResult = lexical.Input(0, text.Length);

            switch (dfaResult)
            {
            case DFAResult.Continue:
                throw new Hubble.Core.SFQL.LexicalAnalysis.LexicalException("Lexical abort at the end of sql");

            case DFAResult.Quit:
                InputLexicalToken(lexical.OutputToken);
                break;

            case DFAResult.ElseQuit:
                InputLexicalToken(lexical.OutputToken);
                break;
            }

            InputLexicalToken(new Lexical.Token());
        }