public static void AddError(Token token, string message) { if (errors.ContainsKey(token)) return; errors.Add(token, message); }
public EngineException(ExceptionType type, string message, Token token) { Type = type; Message = message; Token = token; Line = token.Line; Position = token.Position; }
public EngineException(ExceptionType type, string message) { Type = type; Message = message; Token = new Token(TokenType.IDENTIFIER, "", null); Line = (GetCurrentLine == null) ? 0 : GetCurrentLine(); Position = 0; }
public TokenChars(Token token) { Token = token; Characters = GetCharsByIndices(token.Indices); foreach (var c in Characters) { c.ParentToken = token; } }
private static void PopulateHTMLAttributeList(Token token, List<Token> tokens) { AutoCompleteService.Instance.ClearListboxItems(); // add element-specific attributes if (IsInsideIncompleteAttributeName(token, tokens)) { var element = GetElementWhileTypingAttribute(token, tokens); if (element != null) AddHTMLAttributesToList(element.Attributes); } // add global attributes AddHTMLAttributesToList(GlobalHTMLAttributes); _listState = AutoCompleteListState.Attributes; }
private static bool IsInsideIncompleteTagName(Token token, List<Token> tokens) { return token != null && (token.Type == TokenType.IDENTIFIER || token.Type == TokenType.KEYWORD) && token.Previous(tokens).Value.Equals("<"); }
private static bool IsInsideIncompleteAttributeName(Token token, List<Token> tokens) { Token currentToken; if (token == null) // this is true when the character before caret is white-space currentToken = Controller.Instance.TokenBeforeCaret; else currentToken = token; if (token == null) return false; if (token.Type != TokenType.IDENTIFIER) return false; while (currentToken.Type != TokenType.EOF) { if (currentToken.Value.Equals("<")) return true; if (currentToken.Value.Equals("/")) return false; if (currentToken.Value.Equals(">")) return false; currentToken = currentToken.Previous(tokens); } return false; }
private static HTMLElement GetElementWhileTypingAttribute(Token token, List<Token> tokens) { // this will return the HTMLElement when the user is typing the attributes of that element, i.e. // <img class='rounded' alt='' /> // ^ caret here // on the previous example, it will return the element "img" // if the caret was not inside the brackets, a null will be returned var currentToken = token.Previous(tokens); while (currentToken.Type != TokenType.EOF) { if (currentToken.Value.Equals("<") || currentToken.Value.Equals(">")) break; if (currentToken.Type == TokenType.KEYWORD && currentToken.Previous(tokens).Value.Equals("<")) break; currentToken = currentToken.Previous(tokens); } if (currentToken.Type == TokenType.KEYWORD) { return HTMLElements.SingleOrDefault(e => e.Name.Equals(currentToken.Value)); } return null; }
public void GotoToken(Token token) { currentTokenIndex = tokens.IndexOf(token); if (currentTokenIndex == -1) currentTokenIndex = 0; }
public bool FallsBefore(List<Token> list, Token target) { int selfIndex = Index(list); int targetIndex = list.IndexOf(target); if (selfIndex < targetIndex) return true; return false; }
public static TokenChars GetTokenCharsByToken(this List<TokenChars> tcList, Token t) { foreach (var tc in tcList) { if (tc.Token == t) return tc; } return null; }