示例#1
0
 public void Relation(Token op, OsgItem x, OsgItem y)
 {
     throw new NotImplementedException();
 }
示例#2
0
文件: Scanner.cs 项目: adbrowne/abcm
 internal void Number()
 {
     sym = Token.Number;
     val = 0;
     do
     {
         val *= 10;
         val += Int32.Parse(ch.ToString());
         ReadChar();
     } while (ch.IsNumeric());
 }
示例#3
0
文件: Scanner.cs 项目: adbrowne/abcm
 internal void Ident()
 {
     id = "";
     int i = 0;
     do
     {
         if (i < IdLen)
         {
             id += ch;
             i++;
         }
         ReadChar();
     } while (ch.IsAlphaNum());
     if (keyTable.ContainsKey(id))
         sym = keyTable[id];
     else
         sym = Token.Ident;
 }
示例#4
0
文件: Scanner.cs 项目: adbrowne/abcm
        internal Token Get()
        {
            while (!Eof() && (ch == ' ' || ch == '\n' || ch == '\r'))
            {
                ReadChar();
            }

            if (Eof())
            {
                sym = Token.Eof;
            }
            else if (ch == '&')
            {
                ReadChar();
                sym = Token.And;
            }
            else if (ch == '*')
            {
                ReadChar();
                sym = Token.Times;
            }
            else if (ch == '+')
            {
                ReadChar();
                sym = Token.Plus;
            }
            else if (ch == '-')
            {
                ReadChar();
                sym = Token.Minus;
            }
            else if (ch == '=')
            {
                ReadChar();
                sym = Token.Eql;
            }
            else if (ch == '#')
            {
                ReadChar();
                sym = Token.Neq;
            }
            else if (ch == '<')
            {
                ReadChar();
                if (ch == '=')
                {
                    ReadChar();
                    sym = Token.Leq;
                }
                else
                    sym = Token.Lss;
            }
            else if (ch == '>')
            {
                ReadChar();

                if (ch == '=')
                {
                    sym = Token.Geq;
                }
                else
                    sym = Token.Gtr;
            }
            else if (ch == ';')
            {
                ReadChar();
                sym = Token.Semicolon;
            }
            else if (ch == ',')
            {
                ReadChar();
                sym = Token.Comma;
            }
            else if (ch == ':')
            {
                ReadChar();
                if (ch == '=')
                {
                    ReadChar();
                    sym = Token.Becomes;
                }
                else
                    sym = Token.Colon;
            }
            else if (ch == '.')
            {
                ReadChar();
                sym = Token.Period;
            }
            else if (ch == '(')
            {
                ReadChar();
                if (ch == '*')
                {
                    Comment();
                    sym = Get();
                }
                else
                {
                    sym = Token.Lparen;
                }
            }
            else if (ch == ')')
            {
                ReadChar();
                sym = Token.Rparen;
            }
            else if (ch == '[')
            {
                ReadChar();
                sym = Token.Lbrak;
            }
            else if (ch == ']')
            {
                ReadChar();
                sym = Token.Rbrak;
            }
            else if (ch.IsNumeric())
            {
                Number();
            }
            else if (ch.IsAlpha())
            {
                Ident();
            }
            else if (ch == '~')
            {
                ReadChar();
                sym = Token.Not;
            }
            else
            {
                ReadChar();
                sym = Token.Null;
            }

            return sym;
        }
示例#5
0
文件: Scanner.cs 项目: adbrowne/abcm
 public void EnterKW(Token token, string name)
 {
     keyTable.Add(name, token);
 }
示例#6
0
文件: Parser.cs 项目: adbrowne/abcm
 private void NextToken()
 {
     sym = scanner.Get();
 }