-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#9 Extended token information & removed scanner argument checks
- Loading branch information
1 parent
e4772c1
commit 3092f45
Showing
8 changed files
with
51 additions
and
100 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
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 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,35 +1,12 @@ | ||
using System; | ||
using Mup.Scanner; | ||
|
||
namespace Mup.Creole | ||
{ | ||
internal class CreoleToken : IEquatable<CreoleToken> | ||
internal class CreoleToken : Token<CreoleTokenCode> | ||
{ | ||
public static bool operator ==(CreoleToken left, CreoleToken right) | ||
=> left.Equals(right); | ||
|
||
public static bool operator !=(CreoleToken left, CreoleToken right) | ||
=> !left.Equals(right); | ||
|
||
internal CreoleToken(CreoleTokenCode code, string text) | ||
internal CreoleToken(CreoleTokenCode code, string text, int line, int column) | ||
: base(code, text, line, column) | ||
{ | ||
Code = code; | ||
Text = text; | ||
} | ||
|
||
internal CreoleTokenCode Code { get; } | ||
|
||
internal string Text { get; } | ||
|
||
public bool Equals(CreoleToken other) | ||
=> (Code == other.Code && Text == other.Text); | ||
|
||
public override bool Equals(object obj) | ||
=> (obj != null && ((obj as CreoleToken)?.Equals(this) ?? false)); | ||
|
||
public override int GetHashCode() | ||
=> (new { Code, Text }).GetHashCode(); | ||
|
||
public override string ToString() | ||
=> $"{Code}: {Text}"; | ||
} | ||
} |
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 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,21 @@ | ||
namespace Mup.Scanner | ||
{ | ||
internal class Token<TCode> | ||
{ | ||
public Token(TCode code, string text, int line, int column) | ||
{ | ||
Code = code; | ||
Text = text; | ||
Line = line; | ||
Column = column; | ||
} | ||
|
||
public TCode Code { get; } | ||
|
||
public string Text { get; } | ||
|
||
public int Line { get; } | ||
|
||
public int Column { get; } | ||
} | ||
} |