Пример #1
0
        string GetErrorHTML(string message, Token token)
        {
            int start = Math.Max(token.Position - 150, 0);
            string code = source.Substring(start, token.Position - start);
            string prefix = "", suffix = "";
            int start2 = start + code.Length + token.Value.Length;
            string code2 = source.Substring(start2, Math.Min(150, source.Length - start2));

            if (start > 0) prefix = "...";
            if (source.Length - start2 > 150) suffix = "...";

            return "<style>body{font-family:verdana;font-size:8pt;}</style>"
                    + "<body><h2>Couldn't understand part of the script :(</h2>"
                    + "<strong style=\"color:red\">" + HttpUtility.HtmlEncode(message) + "</strong><br/>"
                    + "The error occurred at position " + token.Position + " in the script, at a section that looks like this:<br/><br/>"
                    + "<div style=\"padding:10px;background-color:#ffd;border:1px dotted #cca;\">"
                    + "<pre style=\"margin:0\">" + prefix + HttpUtility.HtmlEncode(code)
                    + "<span style=\"color:red\">" + HttpUtility.HtmlEncode(token.Value) + "</span>"
                    + HttpUtility.HtmlEncode(code2) + suffix + "</pre></div></body>";
        }
Пример #2
0
 public InstructionExecutionException(string message, Token token)
     : base(message)
 {
     this.token = token;
 }
Пример #3
0
 public static bool IsEnd(Token token)
 {
     return token.Value == "end";
 }
Пример #4
0
 public virtual void BuildExpression(List<Token> tokens, ref int index, Stack<int?> precedenceStack)
 {
     token = tokens[index - 1];
     right = TokenParser.BuildExpression(tokens, ref index, precedenceStack);
 }
Пример #5
0
 public TokenParserException(string message, Token token)
     : base(message)
 {
     this.token = token;
 }