public PostTokenList Parse() { var res = new PostTokenList(); Token last = null; bool know = false; for (var i = 0; i < tokens.Count(); i++) { Token token = tokens[i]; if (token.type != Token.Type.KEYWORD) { if (res.LastFinished(last, know) && !token.CannotOpenWith() && (res.Count == 0 || res.Last.Keyname != "expression")) { res.Add(new PostToken("expression")); } res.Last.AddData(token.value); } else { res.Add(new PostToken(token.value)); } last = token; know = true; } return(res); }
public PostTokenList Select(PostToken.PostTokenType type) { var res = new PostTokenList(); foreach (var token in this) { if (token.type == type) { res.Add(token); } } return(res); }
public PostTokenList Select(string text) { var res = new PostTokenList(); foreach (var token in this) { if (token.Keyname == text) { res.Add(token); } } return(res); }
public PostTokenList CutFrom(PostToken token) { var res = new PostTokenList(); int pos = Pos(token); if (pos == -1) { throw new InternalException("Post token not found"); } for (int i = pos; i < this.Count(); i++) { res.Add(this[i]); } return(res); }
public MathPreprocessor(PostTokenList tokens) { this.tokens = tokens; }