progress
This commit is contained in:
parent
16e76d6b31
commit
484dbfc9d9
529 changed files with 113694 additions and 0 deletions
82
AspClassic.Parser/PunctuatorToken.cs
Normal file
82
AspClassic.Parser/PunctuatorToken.cs
Normal file
|
@ -0,0 +1,82 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AspClassic.Parser;
|
||||
|
||||
/// <summary>
|
||||
/// A punctuation token.
|
||||
/// </summary>
|
||||
public sealed class PunctuatorToken : Token
|
||||
{
|
||||
private static Dictionary<string, TokenType> PunctuatorTable;
|
||||
|
||||
private static void AddPunctuator(Dictionary<string, TokenType> table, string punctuator, TokenType type)
|
||||
{
|
||||
table.Add(punctuator, type);
|
||||
table.Add(Scanner.MakeFullWidth(punctuator), type);
|
||||
}
|
||||
|
||||
internal static TokenType TokenTypeFromString(string s)
|
||||
{
|
||||
if (PunctuatorTable == null)
|
||||
{
|
||||
Dictionary<string, TokenType> Table = new Dictionary<string, TokenType>(StringComparer.InvariantCulture);
|
||||
AddPunctuator(Table, "(", TokenType.LeftParenthesis);
|
||||
AddPunctuator(Table, ")", TokenType.RightParenthesis);
|
||||
AddPunctuator(Table, "{", TokenType.LeftCurlyBrace);
|
||||
AddPunctuator(Table, "}", TokenType.RightCurlyBrace);
|
||||
AddPunctuator(Table, "!", TokenType.Exclamation);
|
||||
AddPunctuator(Table, "#", TokenType.Pound);
|
||||
AddPunctuator(Table, ",", TokenType.Comma);
|
||||
AddPunctuator(Table, ".", TokenType.Period);
|
||||
AddPunctuator(Table, ":", TokenType.Colon);
|
||||
AddPunctuator(Table, ":=", TokenType.ColonEquals);
|
||||
AddPunctuator(Table, "&", TokenType.Ampersand);
|
||||
AddPunctuator(Table, "&=", TokenType.AmpersandEquals);
|
||||
AddPunctuator(Table, "*", TokenType.Star);
|
||||
AddPunctuator(Table, "*=", TokenType.StarEquals);
|
||||
AddPunctuator(Table, "+", TokenType.Plus);
|
||||
AddPunctuator(Table, "+=", TokenType.PlusEquals);
|
||||
AddPunctuator(Table, "-", TokenType.Minus);
|
||||
AddPunctuator(Table, "-=", TokenType.MinusEquals);
|
||||
AddPunctuator(Table, "/", TokenType.ForwardSlash);
|
||||
AddPunctuator(Table, "/=", TokenType.ForwardSlashEquals);
|
||||
AddPunctuator(Table, "\\", TokenType.BackwardSlash);
|
||||
AddPunctuator(Table, "\\=", TokenType.BackwardSlashEquals);
|
||||
AddPunctuator(Table, "^", TokenType.Caret);
|
||||
AddPunctuator(Table, "^=", TokenType.CaretEquals);
|
||||
AddPunctuator(Table, "<", TokenType.LessThan);
|
||||
AddPunctuator(Table, "<=", TokenType.LessThanEquals);
|
||||
AddPunctuator(Table, "=<", TokenType.LessThanEquals);
|
||||
AddPunctuator(Table, "=", TokenType.Equals);
|
||||
AddPunctuator(Table, "<>", TokenType.NotEquals);
|
||||
AddPunctuator(Table, ">", TokenType.GreaterThan);
|
||||
AddPunctuator(Table, ">=", TokenType.GreaterThanEquals);
|
||||
AddPunctuator(Table, "=>", TokenType.GreaterThanEquals);
|
||||
AddPunctuator(Table, "<<", TokenType.LessThanLessThan);
|
||||
AddPunctuator(Table, "<<=", TokenType.LessThanLessThanEquals);
|
||||
AddPunctuator(Table, ">>", TokenType.GreaterThanGreaterThan);
|
||||
AddPunctuator(Table, ">>=", TokenType.GreaterThanGreaterThanEquals);
|
||||
PunctuatorTable = Table;
|
||||
}
|
||||
if (!PunctuatorTable.ContainsKey(s))
|
||||
{
|
||||
return TokenType.None;
|
||||
}
|
||||
return PunctuatorTable[s];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new punctuator token.
|
||||
/// </summary>
|
||||
/// <param name="type">The punctuator token type.</param>
|
||||
/// <param name="span">The location of the punctuator.</param>
|
||||
public PunctuatorToken(TokenType type, Span span)
|
||||
: base(type, span)
|
||||
{
|
||||
if (type < TokenType.LeftParenthesis || type > TokenType.GreaterThanGreaterThanEquals)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("type");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue