示例#1
0
        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);
        }
示例#2
0
 public static bool In(this Lexema l, IEnumerable<LexType> types)
 {
     return types.Contains(l.Type);
 }
示例#3
0
 private void StartLexema()
 {
     curr = new Lexema();
 }
示例#4
0
 public TokenException(Lexema l) : base($"Wrong token `{l.Tok}` at {l.Line}:{l.Symbol}")
 {
 }