Ejemplo n.º 1
0
        public List <SintaxResponseViewModel> GetSintaxAnalisis(string text)
        {
            LexerController lexer = new LexerController(_symbolsHelper);

            _toValidate.Text           = text;
            _toValidate.StringPosition = lexer.FirstCharacterPosition(_toValidate.Text);
            for (int i = _toValidate.StringPosition; i < _toValidate.Text.Length; i++)
            {
                _toValidate.CharToValidate = _toValidate.Text[i];

                if (!_symbolsHelper.IsSemiColon(_toValidate.CharToValidate) &&
                    !_symbolsHelper.IsBracket(_toValidate.CharToValidate))
                {
                    _toValidate.TextToValidate += _toValidate.CharToValidate;
                }

                if (_symbolsHelper.IsSemiColon(_toValidate.CharToValidate) ||
                    _symbolsHelper.IsBracket(_toValidate.CharToValidate))
                {
                    _sintaxResponse.Tokens = lexer.FindToken(_toValidate.TextToValidate);
                    _result.Add(_sintaxResponse);
                    _toValidate.TextToValidate = "";
                }
            }
            return(_result);
        }
Ejemplo n.º 2
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            txtResult.Text = "";
            ToValidateViewModel view = new ToValidateViewModel
            {
                Text = txtCode.Text + " "
            };
            LexerController lexer = new LexerController();
            IEnumerable <TokenViewModel> result = lexer.FindToken(view);

            foreach (var item in result)
            {
                txtResult.Text += $"The token type for {item.Text} is {item.TypeToken.ToString()} \n";
            }
        }
Ejemplo n.º 3
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            txtResult.Text = "";
            ToValidateViewModel view = new ToValidateViewModel
            {
                Text = txtCode.Text + " "
            };
            SintaxController sintax = new SintaxController(_symbolsHelper);
            List <SintaxResponseViewModel> result2 = sintax.GetSintaxAnalisis(txtCode.Text);
            LexerController       lexer            = new LexerController(_symbolsHelper);
            List <TokenViewModel> result           = lexer.FindToken(view);

            foreach (var item in result)
            {
                txtResult.Text += $"Token for {item.Text} is {item.TypeToken.ToString()} and {item.TextToIdentifier}\n";
            }
        }