private Token NextSymbol() { Token token = new Token(); token.Type = TokenType.Symbol; token.Value = this.NextNameAsString(); return token; }
private Token NextReal(string value) { int ch; ch = this.NextChar(); while (ch >= 0 && char.IsDigit((char)ch)) { value += (char)ch; ch = this.NextChar(); } this.PushChar(ch); Token token = new Token(); token.Type = TokenType.Real; token.Value = value; return token; }
private Token NextString() { string value = string.Empty; int ch; while (true) { ch = this.NextChar(); while (ch >= 0 && ch != StringDelimiter) { value += (char)ch; ch = this.NextChar(); } if (ch < 0) break; int ch2 = this.PeekChar(); if (ch2 < 0) break; if (ch2 != StringDelimiter) break; this.NextChar(); value += (char)ch; } if (ch < 0) throw new LexerException("Unclosed string"); Token token = new Token(); token.Type = TokenType.String; token.Value = value; return token; }
private Token NextParameter() { Token token = new Token(); token.Type = TokenType.Parameter; token.Value = this.NextNameAsString(); return token; }
private Token NextPunctuation(char ch) { Token token = new Token(); token.Value = new string(ch, 1); token.Type = TokenType.Punctuation; return token; }
private Token NextName(char firstchar) { StringBuilder sb = new StringBuilder(10); sb.Append(firstchar); int ch; ch = this.NextChar(); while (ch >= 0 && char.IsLetterOrDigit((char)ch)) { sb.Append((char)ch); ch = this.NextChar(); } if (ch >= 0 && ch == '.' && char.IsUpper(firstchar)) { var peek = this.PeekChar(); if (peek >= 0 && char.IsLetter((char)peek) && char.IsUpper((char)peek)) { sb.Append((char)ch); return this.NextDottedName(sb.ToString()); } this.PushChar(ch); } else if (ch >= 0 && ch == ':') { sb.Append((char)ch); } else { this.PushChar(ch); } Token token = new Token(); token.Type = TokenType.Name; token.Value = sb.ToString(); return token; }
private Token NextOperator(char firstchar) { string value = new string(firstchar, 1); if (firstchar != '^') { int ch; ch = this.NextChar(); while (ch >= 0 && Operators.IndexOf((char)ch) >= 0) { value += (char)ch; ch = this.NextChar(); } this.PushChar(ch); } Token token = new Token(); token.Type = TokenType.Operator; token.Value = value; return token; }
private Token NextInteger(char firstdigit) { string value = new string(firstdigit, 1); int ch; ch = this.NextChar(); while (ch >= 0 && char.IsDigit((char)ch)) { value += (char)ch; ch = this.NextChar(); } if (ch == '.') { int ch2 = this.PeekChar(); if (ch2 >= 0 && char.IsDigit((char)ch2)) return this.NextReal(value + "."); } if (ch >= 0 && ch == 'r') { value += (char)ch; for (ch = this.NextChar(); ch >= 0 && char.IsLetterOrDigit((char)ch); ch = this.NextChar()) value += (char)ch; } this.PushChar(ch); Token token = new Token(); token.Type = TokenType.Integer; token.Value = value; return token; }
private Token NextEnclosedSymbol() { StringBuilder sb = new StringBuilder(10); int ch; ch = this.NextChar(); while (ch >= 0 && ch != '}') { sb.Append((char)ch); ch = this.NextChar(); } if (ch != '}') new LexerException("Expected '}'"); Token token = new Token(); token.Type = TokenType.Symbol; token.Value = sb.ToString(); return token; }
private Token NextDotNetTypeName() { StringBuilder sb = new StringBuilder(); sb.Append(SpecialDotNetTypeMark); int ch; ch = this.NextChar(); while (ch >= 0 && (char.IsLetterOrDigit((char)ch) || ch == '.')) { sb.Append((char)ch); ch = this.NextChar(); } this.PushChar(ch); Token token = new Token(); token.Type = TokenType.Name; token.Value = sb.ToString(); return token; }
public void PushToken(Token token) { this.tokenstack.Push(token); }
private void PushToken(Token token) { this.tokenizer.PushToken(token); }