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>"; }
public InstructionExecutionException(string message, Token token) : base(message) { this.token = token; }
public static bool IsEnd(Token token) { return token.Value == "end"; }
public virtual void BuildExpression(List<Token> tokens, ref int index, Stack<int?> precedenceStack) { token = tokens[index - 1]; right = TokenParser.BuildExpression(tokens, ref index, precedenceStack); }
public TokenParserException(string message, Token token) : base(message) { this.token = token; }