Skip to content

Commit

Permalink
Добавил диагностический Exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-raevskiy committed Sep 3, 2014
1 parent 3bb794f commit 5b4ab7b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dwarf-cs/dwarf.core/lang/Lexer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public IEnumerable<Token> Tokenize(string source)

var state = 0;
var pos = 0;
var tok = "";

// HACK
source += (char) 0xffff;
Expand All @@ -194,6 +195,7 @@ public IEnumerable<Token> Tokenize(string source)
matcher.Reset();
}

tok = "";
state = 1;
}

Expand All @@ -214,6 +216,12 @@ public IEnumerable<Token> Tokenize(string source)
break;
}
}

if (token == null && source[pos] != 0xffff)
{
tok += source[pos];
throw new Exception(String.Format("Unknown token: {0}", tok));
}
}

if (token != null)
Expand All @@ -223,6 +231,7 @@ public IEnumerable<Token> Tokenize(string source)
}
else
{
tok += source[pos];
pos ++;
}
}
Expand Down

0 comments on commit 5b4ab7b

Please sign in to comment.