private Lexema EndLexema() { var v = 0; try { if (curr.Type == LexType.Tintd) { // ReSharper disable once ReturnValueOfPureMethodIsNotUsed v = int.Parse(curr.Tok); } else if (curr.Type == LexType.Tinth && curr.Tok.Substring(2).Length > 0) { v = int.Parse(curr.Tok.Substring(2), NumberStyles.HexNumber); } else if (curr.Type == LexType.Tinto) { // ReSharper disable once ReturnValueOfPureMethodIsNotUsed v = Convert.ToInt32(curr.Tok, 8); } } catch (OverflowException) { SetLexType(LexType.Terr); } var t = curr; curr = null; t.Line = line; t.IntValue = v; t.Symbol = Symbol; return(t); }
public static bool In(this Lexema l, IEnumerable<LexType> types) { return types.Contains(l.Type); }
private void StartLexema() { curr = new Lexema(); }
public TokenException(Lexema l) : base($"Wrong token `{l.Tok}` at {l.Line}:{l.Symbol}") { }