Пример #1
0
 void label_ValidateToken(object sender, ValidateTokenEventArgs e)
 {
     //check that token starts at position 0
     if (e.Token.Location.Column > 0) //Column is 0-based
     {
         e.RejectToken();
     }
 }//constructor
 private void KeywordAdded(object sender, ValidateTokenEventArgs ea)
 {
     if (_nodes.SelectedNode?.Tag is ThreatSourceNodeParentChild node)
     {
         var list = new List <EditToken>(_keywords.SelectedTokens);
         list.Add(ea.Token);
         _associatedKeywords[node.Node.Id] = list.ToArray();
     }
 }
Пример #3
0
 public static void SetError(this ValidateTokenEventArgs e, string errorMessage, params object[] messageArgs)
 {
     e.Context.CurrentToken = e.Context.CreateErrorToken(errorMessage, messageArgs);
 }
Пример #4
0
 public static void ReplaceToken(this ValidateTokenEventArgs e, Token token)
 {
     e.Context.CurrentToken = token;
 }
Пример #5
0
 //Rejects the token; use it when there's more than one terminal that can be used to scan the input and ValidateToken is used
 // to help Scanner make the decision. Once the token is rejected, the scanner will move to the next Terminal (with lower priority)
 // and will try to produce token.
 public static void RejectToken(this ValidateTokenEventArgs e)
 {
     e.Context.CurrentToken = null;
 }
Пример #6
0
 private void _appliesTo_ValidateToken(object sender, ValidateTokenEventArgs ea)
 {
     ea.IsValid = !ea.IsNewToken;
 }
Пример #7
0
 // Remove this when it appears in Irony (if ever). See https://irony.codeplex.com/discussions/438247#post1026398
 /// <summary>
 /// Replace the current token with a token based on <paramref name="newTerminal"/>, while keeping everything else
 /// the same as the current token.
 /// </summary>
 /// <param name="newTerminal"></param>
 public static void ReplaceToken(this ValidateTokenEventArgs @this, Terminal newTerminal)
 {
     @this.ReplaceToken(new Token(newTerminal, @this.Context.CurrentToken.Location, @this.Context.CurrentToken.Text, @this.Context.CurrentToken.Value));
 }
Пример #8
0
 //All numbers are treated as HEX initially; here we need to analyze suffix (if any) and convert the value
 void number_ValidateToken(object sender, ValidateTokenEventArgs e)
 {
 }
Пример #9
0
 private void OnValidateToken(object sender, ValidateTokenEventArgs ea)
 {
     ea.IsValid = !(SelectedTokens?.Contains(ea.Token) ?? false);
 }