Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Created October 26, 2016 03:28
Show Gist options
  • Select an option

  • Save toptensoftware/d8b0bf3eb85e6b7bf0d52c9743de3dbd to your computer and use it in GitHub Desktop.

Select an option

Save toptensoftware/d8b0bf3eb85e6b7bf0d52c9743de3dbd to your computer and use it in GitHub Desktop.
// Identifier - starts with letter or underscore
if (char.IsLetter(_currentChar) || _currentChar == '_')
{
var sb = new StringBuilder();
// Accept letter, digit or underscore
while (char.IsLetterOrDigit(_currentChar) || _currentChar == '_')
{
sb.Append(_currentChar);
NextChar();
}
// Setup token
_identifier = sb.ToString();
_currentToken = Token.Identifier;
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment