using System.Collections.Generic;
public static void Main()
Scanner scanner = new Scanner();
List<Token> tokens = scanner.Scan("12375 + 234 / 88");
foreach (var token in tokens) {
Console.WriteLine(token);
ADDITION, SUBTRACTION, DIVISION, MULTIPLICATION
public Token(string lexeme, TokenType type) {
public override string ToString() {
return Lexeme + " as " + Type.ToString();
public List<Token> Scan(string ogcontent){
tokens = new List<Token>();
switch(content[current]){
case '+' : tokens.Add(new Token("+", TokenType.ADDITION)); break;
case '-' : tokens.Add(new Token("-", TokenType.SUBTRACTION)); break;
case '*' : tokens.Add(new Token("*", TokenType.MULTIPLICATION)); break;
case '/' : tokens.Add(new Token("/", TokenType.DIVISION)); break;
if(IsNumeric(content[current])) {
}else if (IsAlpha(content[current])) {
throw new ArgumentException("Unexpected character " + content[current]);
if(current == content.Length)
private void HandleNumber(){
if(current < content.Length-1 && IsNumeric(content[current+1]))
tokens.Add(new Token(content.Substring(start, current-start+1), TokenType.NUMBER));
private void HandleIdentifier(){
private bool IsNumeric(char c) {
private bool IsAlpha(char c) {