private void ColoriseRho()
        {
            CheckFonts();

            var rtb = rhoInput;

            BeginUpdate(rtb);

            var input = rtb.Text + " \n";
            var lex   = new RhoLexer(input);

            try
            {
                DefaultColors(lex, input);

                lex.Process();

                foreach (var tok in lex.Tokens)
                {
                    ColoriseRhoToken(tok, tok.Slice);
                }
            }
            catch (Exception e)
            {
                output.Text = $"{e.Message}: {lex.Error}";
            }
            finally
            {
                EndUpdate(rtb);
            }
        }
Example #2
0
        public void TestParse()
        {
            var input = "1\n";
            var lex   = new RhoLexer(input);

            lex.Process();
            var slice = new Slice(lex, 0, input.Length - 1)
            {
                LineNumber = 0
            };

            Console.WriteLine(slice.Text);
        }
        public string Colorise(string text)
        {
            if (string.IsNullOrEmpty(text))
            {
                return(string.Empty);
            }

            BeginUpdate();
            var lex = new RhoLexer(text);

            _sb = new StringBuilder();
            try
            {
                lex.Process();

                foreach (var tok in lex.Tokens)
                {
                    switch (tok.Type)
                    {
                    case ERhoToken.Nop:
                        continue;

                    case ERhoToken.NewLine:
                        _sb.Append('\n');
                        continue;
                    }

                    //Debug.Log(tok);

                    ColoriseRhoToken(tok, tok.Slice);
                }
            }
            catch (Exception e)
            {
                Debug.Log(e.StackTrace);
                Debug.LogError($"{e.Message}");
                _sb.Clear();
                _sb.Append(text);
            }
            finally
            {
                EndUpdate();
            }

            return(_sb.ToString());
        }