PutBack() 개인적인 메소드

private PutBack ( char ch ) : void
ch char
리턴 void
 protected internal void PutBack(TSymbol symbol)
 {
     if (symbol != null)
     {
         Tokenizer.PutBack(symbol);
     }
 }
예제 #2
0
        public int ReadEqChar(Tokenizer t)
        {
            Token tok;

            ReadEq(t);
            tok = t.Read();

            if (tok.Type == TokenType.StringQuoteStart)
            {
                string text;

                t.PutBack(tok);
                text = ReadString(t);

                text = text.Replace("\\b", "\b");
                text = text.Replace("\\t", "\t");
                text = text.Replace("\\n", "\n");
                text = text.Replace("\\'", "'");
                text = text.Replace("\\\"", "\"");
                text = text.Replace("\\\\", "\\");

                if (text.Length != 1)
                {
                    throw new Exception(tok.PositionString + ": Expected one character, not string '" + text + "'");
                }

                return(text [0]);
            }
            else if (tok.Text == "@")
            {
                tok = t.Read();

                if (tok.Type != TokenType.Alphanumeric)
                {
                    throw new UnexpectedTokenException(tok, "<special-key>");
                }

                return((int)Enum.Parse(typeof(SpecialKeys), tok.Text));
            }
            else
            {
                t.PutBack(tok);
                return(ReadInt(t));
            }
        }
예제 #3
0
        public Keymap ReadMap(Tokenizer t)
        {
            Keymap map = new Keymap();
            Token  tok;

            ReadSectionOpen(t);

            do
            {
                int scancode, key;

                tok = t.Read();

                if (tok == null)
                {
                    throw new UnexpectedEndOfFileException(t, "}");
                }

                if (tok.Text == "}")
                {
                    break;
                }
                else
                {
                    t.PutBack(tok);
                }

                scancode = ReadInt(t);

                key = ReadEqChar(t);
                ReadEnd(t);

                map.Entries [scancode] = key;
            } while (true);

            return(map);
        }