예제 #1
0
파일: Converter.cs 프로젝트: 7shi/cs2fs
 public Converter(Token[] tokens)
 {
     if (Converter.noop == null)
     {
         Converter.noop = new[]
         {
             "++", "--", "??", "?:","+=", "-=", "*=", "/=",
             "%=", "&=", "|=", "^=", "<<=", ">>=", "=>", "?", ":"
         };
     }
     this.usings = new List<string>();
     this.tokens = tokens.Where(delegate(Token t)
     {
         return !t.CanOmit;
     }).ToArray();
     this.last = new Token("", TokenType.None, 0, 0);
     if (this.tokens.Length > 0)
         this.cur = this.tokens[0];
     else
         this.cur = this.last;
 }
예제 #2
0
파일: Lexer.cs 프로젝트: knat/CSharpParser
 private Token GetPpExprTokenCore()
 {
     TextSpan ts;
     var s = TryGetPpIdentifier(out ts);
     if (s != null)
     {
         return new Token(TokenKind.NormalIdentifier, s, ts);
     }
     var ch = GetChar();
     if (ch == '|')
     {
         var nextch = GetNextChar();
         if (nextch == '|')
         {
             MarkTokenStart();
             ConsumeChar();
             ConsumeChar();
             return CreateToken(TokenKind.BarBar);
         }
     }
     else if (ch == '&')
     {
         var nextch = GetNextChar();
         if (nextch == '&')
         {
             MarkTokenStart();
             ConsumeChar();
             ConsumeChar();
             return CreateToken(TokenKind.AmpersandAmpersand);
         }
     }
     else if (ch == '=')
     {
         var nextch = GetNextChar();
         if (nextch == '=')
         {
             MarkTokenStart();
             ConsumeChar();
             ConsumeChar();
             return CreateToken(TokenKind.EqualsEquals);
         }
     }
     else if (ch == '!')
     {
         var nextch = GetNextChar();
         if (nextch == '=')
         {
             MarkTokenStart();
             ConsumeChar();
             ConsumeChar();
             return CreateToken(TokenKind.ExclamationEquals);
         }
     }
     else if (ch == '/')
     {
         var nextch = GetNextChar();
         if (nextch == '/')
         {
             MarkTokenStart();
             ConsumeChar();
             ConsumeChar();
             while (true)
             {
                 ch = GetChar();
                 if (ch == char.MaxValue || SyntaxFacts.IsNewLine(ch))
                 {
                     break;
                 }
                 ConsumeChar();
             }
             return CreateToken(TokenKind.SingleLineComment);
         }
     }
     var tk = new Token(ch, null, CreateSingleTextSpan());
     ConsumeChar(true);
     return tk;
 }
예제 #3
0
파일: Converter.cs 프로젝트: 7shi/cs2fs
 private void MoveNext()
 {
     if (this.pos < this.tokens.Length)
     {
         this.pos = this.pos + 1;
         if (this.pos < this.tokens.Length)
             this.cur = this.tokens[this.pos];
         else
             this.cur = this.last;
     }
     else
         this.cur = this.last;
 }
예제 #4
0
파일: Lexer.cs 프로젝트: knat/CSharpParser
 private Token CreateTokenAndConsumeChar(char ch)
 {
     _atLineHead = false;
     _gotNonTrivalToken = true;
     var token = new Token(ch, null, CreateSingleTextSpan());
     ConsumeChar();
     return token;
 }