-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose the tokeniser to the public API
- Loading branch information
1 parent
1698a57
commit 7e50cce
Showing
7 changed files
with
113 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Sledge.Formats.Tokens | ||
{ | ||
public interface ITokenReader | ||
{ | ||
Token Read(char start, TextReader reader); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
|
||
namespace Sledge.Formats.Tokens | ||
{ | ||
public class Token | ||
{ | ||
public TokenType Type { get; } | ||
public string CustomType { get; } | ||
public string Value { get; } | ||
public int Line { get; set; } | ||
public int Column { get; set; } | ||
|
||
public char Symbol | ||
{ | ||
get | ||
{ | ||
if (Type != TokenType.Symbol || Value == null || Value.Length != 1) throw new ArgumentException($"Not a symbol: {Type}({Value})"); | ||
return Value[0]; | ||
} | ||
} | ||
|
||
public Token(TokenType type, string value = null) | ||
{ | ||
Type = type; | ||
Value = value; | ||
} | ||
|
||
public Token(string customType, string value = null) | ||
{ | ||
Type = TokenType.Custom; | ||
CustomType = customType; | ||
Value = value; | ||
} | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
Sledge.Formats/Valve/ValveTokenType.cs → Sledge.Formats/Tokens/TokenType.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
namespace Sledge.Formats.Valve | ||
namespace Sledge.Formats.Tokens | ||
{ | ||
internal enum ValveTokenType | ||
public enum TokenType | ||
{ | ||
Invalid, | ||
Symbol, | ||
Name, | ||
String, | ||
Custom, | ||
End | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.