Skip to content

Commit

Permalink
Identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
czhower committed Aug 27, 2017
1 parent f64cff6 commit cf66e33
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 2 additions & 1 deletion source/Spruce/Tokens/AlphaNum.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
{
public class AlphaNum : Token
{
public AlphaNum() : this("") { }
// First char cannot be digit
public AlphaNum() : base(Chars.AlphaNum, Chars.Alpha) { }
public AlphaNum(string aExtraChars, string aExtraFirstChars = "") : base(aExtraChars + Chars.Digit, aExtraFirstChars + Chars.Digit) { }

public override object Check(string aText)
{
Expand Down
3 changes: 2 additions & 1 deletion source/Spruce/Tokens/Compound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public class Compound : Token {
public override object Parse(string aText, ref int rStart) {
int xOrigStart = rStart;
foreach (var xToken in mInternals) {
if (xToken.Check(aText) == null) {
if (xToken.Parse(aText, ref rStart) == null) {
rStart = xOrigStart;
return null;
}
}
Expand Down
10 changes: 10 additions & 0 deletions source/XSharp/Tokens/Identifier.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace XSharp.Tokens {
public class Identifier : Spruce.Tokens.AlphaNum {
public Identifier() : base("_", "_") {
}
}
}

0 comments on commit cf66e33

Please sign in to comment.