예제 #1
0
        public static Obj ParseSymb(Obj obj)
        {
            string str = obj.GetString();
            int    id  = SymbTable.StrToIdx(str);

            return(SymbObj.Get(id));
        }
예제 #2
0
        static SymbTable()
        {
            int len = defaultSymbols.Length;

            for (int i = 0; i < len; i++)
            {
                string str = defaultSymbols[i];
                symbTable.Add(str);
                symbMap.Add(str, i);
                symbObjs.Add(new SymbObj(i));
            }

            for (int i = 0; i < Generated.EmbeddedSymbols.Length; i++)
            {
                int idx = SymbTable.StrToIdx(Generated.EmbeddedSymbols[i]);
                Miscellanea.Assert(idx == i);
            }
        }
예제 #3
0
        static long ReadSymbol(byte[] text, uint length, long offset, Token token)
        {
            long i = offset;

            while (++i < length)
            {
                byte ch = text[i];
                if (ch == '_')
                {
                    if (++i == length)
                    {
                        return(-i - 1);
                    }
                    ch = text[i];
                    if (!Char.IsLower((char)ch) & !Char.IsDigit((char)ch))
                    {
                        return(-i - 1);
                    }
                }
                else if (!Char.IsLower((char)ch) & !Char.IsDigit((char)ch))
                {
                    break;
                }
            }

            if (token != null)
            {
                long   len   = i - offset;
                char[] chars = new char[len];
                for (int j = 0; j < len; j++)
                {
                    chars[j] = (char)text[offset + j];
                }

                token.offset = offset;
                token.length = len;
                token.type   = TokenType.Symbol;
                token.value  = SymbObj.Get(SymbTable.StrToIdx(new string(chars)));
            }

            return(i);
        }
예제 #4
0
 override public string Tag()
 {
     return(SymbTable.IdxToStr(tagId));
 }
예제 #5
0
 override public string AsSymb()
 {
     return(SymbTable.IdxToStr(id));
 }