public static string Parse(string input, List <IToken> tokens) { var token = ParseUtilities.EatWhiteSpace(input); var position = token.IndexOf(':'); if (position == 0) { tokens.Add(new AssignmentToken()); return(token.Substring(position + 1)); } return(input); }
public static string Parse(string input, List <IToken> tokens) { var token = ParseUtilities.EatWhiteSpace(input); var length = token.IndexOf(' ') > 0 ? token.IndexOf(' ') : token.Length; if (token.Length > 0 && char.IsLetter(token[0])) { tokens.Add(new SymbolToken(input.Substring(0, length))); return(token.Substring(length)); } return(input); }
public static string Parse(string input, List <IToken> tokens) { var token = ParseUtilities.EatWhiteSpace(input); var startPosition = token.IndexOf('('); var endPosition = token.IndexOf(')'); if (startPosition == 0 && endPosition > (startPosition + 1)) { tokens.Add(new SymbolDefinitionToken(token.Substring(startPosition, endPosition - startPosition + 1).Trim(new char[] { '(', ')' }))); return(token.Substring(endPosition + 1)); } return(input); }
public static string Parse(string input, List <IToken> tokens) { var token = ParseUtilities.EatWhiteSpace(input); var start = 0; var length = 0; for (var i = 1; i <= token.Length; i++) { if (double.TryParse(token.Substring(0, i), out var number)) { length = i; } } if (length > start) { tokens.Add(new NumberToken(double.Parse(token.Substring(0, length)))); return(token.Substring(length)); } return(input); }