예제 #1
0
 private void SaveStateAndPos(Scanner.Context ctx)
 {
     ctx.bPos  = this.buffer.Position;
     ctx.cNum  = this._cNum;
     ctx.state = this._state;
     ctx.cChr  = this._chr;
 }
예제 #2
0
 private void RestoreStateAndPos(Scanner.Context ctx)
 {
     this.buffer.Position = ctx.bPos;
     this._cNum           = ctx.cNum;
     this._state          = ctx.state;
     this._chr            = ctx.cChr;
 }
예제 #3
0
 private Scanner.Result Recurse2(Scanner.Context ctx, int next)
 {
     this.SaveStateAndPos(ctx);
     this._state = next;
     if (this._state != 0)
     {
         this.GetChr();
         bool flag = false;
         while (true)
         {
             int num = this.NextState();
             next = num;
             if (num == this._currentStart)
             {
                 break;
             }
             if (flag && next > 22)
             {
                 this.SaveStateAndPos(ctx);
             }
             this._state = next;
             if (this._state == 0)
             {
                 return(Scanner.Result.accept);
             }
             this.GetChr();
             flag = this._state <= 22;
         }
         if (!flag)
         {
             return(Scanner.Result.noMatch);
         }
         else
         {
             return(Scanner.Result.accept);
         }
     }
     else
     {
         return(Scanner.Result.accept);
     }
 }
예제 #4
0
 private int Scan()
 {
     while (true)
     {
         bool flag = false;
         this._state = this._currentStart;
         while (this.NextState() == this._state)
         {
             this.GetChr();
         }
         this.MarkToken();
         while (true)
         {
             int num  = this.NextState();
             int num1 = num;
             if (num == this._currentStart)
             {
                 break;
             }
             if (!flag || num1 <= 22)
             {
                 this._state = num1;
                 this.GetChr();
                 if (this._state <= 22)
                 {
                     flag = true;
                 }
             }
             else
             {
                 Scanner.Context context = new Scanner.Context();
                 Scanner.Result  result  = this.Recurse2(context, num1);
                 if (result != Scanner.Result.noMatch)
                 {
                     break;
                 }
                 this.RestoreStateAndPos(context);
                 break;
             }
         }
         if (this._state <= 22)
         {
             this.MarkEnd();
             int num2 = this._state;
             if (num2 == 0)
             {
                 return(2);
             }
             else if (num2 == 1)
             {
                 continue;
             }
             else if (num2 == 2)
             {
                 return(29);
             }
             else if (num2 == 3 || num2 == 12 || num2 == 13 || num2 == 15)
             {
                 this.yyerror("Illegal input", new object[0]);
                 continue;
             }
             else if (num2 == 4)
             {
                 return(13);
             }
             else if (num2 == 5)
             {
                 return(14);
             }
             else if (num2 == 6)
             {
                 return(15);
             }
             else if (num2 == 7)
             {
                 return(16);
             }
             else if (num2 == 8)
             {
                 return(17);
             }
             else if (num2 == 9)
             {
                 return(18);
             }
             else if (num2 == 10)
             {
                 return(19);
             }
             else if (num2 == 11)
             {
                 return(20);
             }
             else if (num2 == 14)
             {
                 this.yylval.StringValue = this.Yytext;
                 string lower = this.Yytext.ToLower(CultureInfo.InvariantCulture);
                 string str   = lower;
                 if (lower != null)
                 {
                     if (str == "issue")
                     {
                         return(5);
                     }
                     else
                     {
                         if (str == "type")
                         {
                             return(8);
                         }
                         else
                         {
                             if (str == "value")
                             {
                                 return(9);
                             }
                             else
                             {
                                 if (str == "valuetype")
                                 {
                                     return(10);
                                 }
                                 else
                                 {
                                     if (str == "claim")
                                     {
                                         return(12);
                                     }
                                 }
                             }
                         }
                     }
                 }
                 return(3);
             }
             else if (num2 == 16)
             {
                 this.yylval.StringValue = this.Yytext;
                 string lower1 = this.Yytext.ToLower(CultureInfo.InvariantCulture);
                 string str1   = lower1;
                 if (lower1 != null)
                 {
                     if (str1 == "\"int64\"")
                     {
                         return(21);
                     }
                     else
                     {
                         if (str1 == "\"uint64\"")
                         {
                             return(22);
                         }
                         else
                         {
                             if (str1 == "\"string\"")
                             {
                                 return(23);
                             }
                             else
                             {
                                 if (str1 == "\"boolean\"")
                                 {
                                     return(24);
                                 }
                             }
                         }
                     }
                 }
                 return(4);
             }
             else if (num2 == 17)
             {
                 return(30);
             }
             else if (num2 == 18)
             {
                 return(26);
             }
             else if (num2 == 19)
             {
                 return(28);
             }
             else if (num2 == 20)
             {
                 return(25);
             }
             else if (num2 == 21)
             {
                 return(7);
             }
             else if (num2 == 22)
             {
                 break;
             }
         }
         else
         {
             this._state = this._currentStart;
         }
     }
     return(27);
 }
예제 #5
0
파일: Scanner.cs 프로젝트: nickchal/pash
		private int Scan()
		{
			while (true)
			{
				bool flag = false;
				this._state = this._currentStart;
				while (this.NextState() == this._state)
				{
					this.GetChr();
				}
				this.MarkToken();
				while (true)
				{
					int num = this.NextState();
					int num1 = num;
					if (num == this._currentStart)
					{
						break;
					}
					if (!flag || num1 <= 22)
					{
						this._state = num1;
						this.GetChr();
						if (this._state <= 22)
						{
							flag = true;
						}
					}
					else
					{
						Scanner.Context context = new Scanner.Context();
						Scanner.Result result = this.Recurse2(context, num1);
						if (result != Scanner.Result.noMatch)
						{
							break;
						}
						this.RestoreStateAndPos(context);
						break;
					}
				}
				if (this._state <= 22)
				{
					this.MarkEnd();
					int num2 = this._state;
					if (num2 == 0)
					{
						return 2;
					}
					else if (num2 == 1)
					{
						continue;
					}
					else if (num2 == 2)
					{
						return 29;
					}
					else if (num2 == 3 || num2 == 12 || num2 == 13 || num2 == 15)
					{
						this.yyerror("Illegal input", new object[0]);
						continue;
					}
					else if (num2 == 4)
					{
						return 13;
					}
					else if (num2 == 5)
					{
						return 14;
					}
					else if (num2 == 6)
					{
						return 15;
					}
					else if (num2 == 7)
					{
						return 16;
					}
					else if (num2 == 8)
					{
						return 17;
					}
					else if (num2 == 9)
					{
						return 18;
					}
					else if (num2 == 10)
					{
						return 19;
					}
					else if (num2 == 11)
					{
						return 20;
					}
					else if (num2 == 14)
					{
						this.yylval.StringValue = this.Yytext;
						string lower = this.Yytext.ToLower(CultureInfo.InvariantCulture);
						string str = lower;
						if (lower != null)
						{
							if (str == "issue")
							{
								return 5;
							}
							else
							{
								if (str == "type")
								{
									return 8;
								}
								else
								{
									if (str == "value")
									{
										return 9;
									}
									else
									{
										if (str == "valuetype")
										{
											return 10;
										}
										else
										{
											if (str == "claim")
											{
												return 12;
											}
										}
									}
								}
							}
						}
						return 3;
					}
					else if (num2 == 16)
					{
						this.yylval.StringValue = this.Yytext;
						string lower1 = this.Yytext.ToLower(CultureInfo.InvariantCulture);
						string str1 = lower1;
						if (lower1 != null)
						{
							if (str1 == "\"int64\"")
							{
								return 21;
							}
							else
							{
								if (str1 == "\"uint64\"")
								{
									return 22;
								}
								else
								{
									if (str1 == "\"string\"")
									{
										return 23;
									}
									else
									{
										if (str1 == "\"boolean\"")
										{
											return 24;
										}
									}
								}
							}
						}
						return 4;
					}
					else if (num2 == 17)
					{
						return 30;
					}
					else if (num2 == 18)
					{
						return 26;
					}
					else if (num2 == 19)
					{
						return 28;
					}
					else if (num2 == 20)
					{
						return 25;
					}
					else if (num2 == 21)
					{
						return 7;
					}
					else if (num2 == 22)
					{
						break;
					}
				}
				else
				{
					this._state = this._currentStart;
				}
			}
			return 27;
		}