⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csharpparser.cs

📁 C#编写的c#编译器
💻 CS
📖 第 1 页 / 共 5 页
字号:
			case LONG:
			case ULONG:
			case CHAR:
			case FLOAT:
			case DOUBLE:
			{
				value_type();
				if (0 == inputState.guessing)
				{
					astFactory.addASTChild(currentAST, returnAST);
				}
				non_array_type_AST = currentAST.root;
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			 }
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_13_);
			}
			else
			{
				throw;
			}
		}
		returnAST = non_array_type_AST;
	}
	
	public void rank_specifiers() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST rank_specifiers_AST = null;
		
		try {      // for error handling
			{ // ( ... )+
			int _cnt32=0;
			for (;;)
			{
				if ((LA(1)==LBRACK) && (LA(2)==COMMA||LA(2)==RBRACK))
				{
					array_rank();
					if (0 == inputState.guessing)
					{
						astFactory.addASTChild(currentAST, returnAST);
					}
				}
				else
				{
					if (_cnt32 >= 1) { goto _loop32_breakloop; } else { throw new NoViableAltException(LT(1), getFilename());; }
				}
				
				_cnt32++;
			}
_loop32_breakloop:			;
			}    // ( ... )+
			rank_specifiers_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_5_);
			}
			else
			{
				throw;
			}
		}
		returnAST = rank_specifiers_AST;
	}
	
	public void interface_type() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST interface_type_AST = null;
		
		try {      // for error handling
			type_name();
			if (0 == inputState.guessing)
			{
				astFactory.addASTChild(currentAST, returnAST);
			}
			interface_type_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_1_);
			}
			else
			{
				throw;
			}
		}
		returnAST = interface_type_AST;
	}
	
	public void delegate_type() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST delegate_type_AST = null;
		
		try {      // for error handling
			type_name();
			if (0 == inputState.guessing)
			{
				astFactory.addASTChild(currentAST, returnAST);
			}
			delegate_type_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_1_);
			}
			else
			{
				throw;
			}
		}
		returnAST = delegate_type_AST;
	}
	
	public void array_rank() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST array_rank_AST = null;
		int cnt=1;
		
		try {      // for error handling
			AST tmp23_AST = null;
			tmp23_AST = astFactory.create(LT(1));
			match(LBRACK);
			{    // ( ... )*
				for (;;)
				{
					if ((LA(1)==COMMA))
					{
						AST tmp24_AST = null;
						tmp24_AST = astFactory.create(LT(1));
						match(COMMA);
						if (0==inputState.guessing)
						{
							cnt++;
						}
					}
					else
					{
						goto _loop35_breakloop;
					}
					
				}
_loop35_breakloop:				;
			}    // ( ... )*
			AST tmp25_AST = null;
			tmp25_AST = astFactory.create(LT(1));
			match(RBRACK);
			if (0==inputState.guessing)
			{
				array_rank_AST = (AST)currentAST.root;
				array_rank_AST =	 
							(AST)astFactory.make( (new ASTArray(2)).add(array_rank_AST).add((DDW.CSharp.Parse.ArrayRankExpr) astFactory.create(ArrayRankExpr,cnt.ToString())));
						
				currentAST.root = array_rank_AST;
				if ( (null != array_rank_AST) && (null != array_rank_AST.getFirstChild()) )
					currentAST.child = array_rank_AST.getFirstChild();
				else
					currentAST.child = array_rank_AST;
				currentAST.advanceChildToEnd();
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_5_);
			}
			else
			{
				throw;
			}
		}
		returnAST = array_rank_AST;
	}
	
	public void variable_reference() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST variable_reference_AST = null;
		
		try {      // for error handling
			expression();
			if (0 == inputState.guessing)
			{
				astFactory.addASTChild(currentAST, returnAST);
			}
			variable_reference_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_14_);
			}
			else
			{
				throw;
			}
		}
		returnAST = variable_reference_AST;
	}
	
	public void expression() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST expression_AST = null;
		
		try {      // for error handling
			bool synPredMatched126 = false;
			if (((tokenSet_15_.member(LA(1))) && (tokenSet_16_.member(LA(2)))))
			{
				int _m126 = mark();
				synPredMatched126 = true;
				inputState.guessing++;
				try {
					{
						conditional_expression();
					}
				}
				catch (RecognitionException)
				{
					synPredMatched126 = false;
				}
				rewind(_m126);
				inputState.guessing--;
			}
			if ( synPredMatched126 )
			{
				conditional_expression();
				if (0 == inputState.guessing)
				{
					astFactory.addASTChild(currentAST, returnAST);
				}
				expression_AST = currentAST.root;
			}
			else if ((tokenSet_15_.member(LA(1))) && (tokenSet_17_.member(LA(2)))) {
				assignment();
				if (0 == inputState.guessing)
				{
					astFactory.addASTChild(currentAST, returnAST);
				}
				expression_AST = currentAST.root;
			}
			else
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_18_);
			}
			else
			{
				throw;
			}
		}
		returnAST = expression_AST;
	}
	
	public void argument_list() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST argument_list_AST = null;
		
		try {      // for error handling
			argument();
			if (0 == inputState.guessing)
			{
				astFactory.addASTChild(currentAST, returnAST);
			}
			{    // ( ... )*
				for (;;)
				{
					if ((LA(1)==COMMA))
					{
						match(COMMA);
						argument();
						if (0 == inputState.guessing)
						{
							astFactory.addASTChild(currentAST, returnAST);
						}
					}
					else
					{
						goto _loop39_breakloop;
					}
					
				}
_loop39_breakloop:				;
			}    // ( ... )*
			if (0==inputState.guessing)
			{
				argument_list_AST = (AST)currentAST.root;
				argument_list_AST = (AST)astFactory.make( (new ASTArray(2)).add((DDW.CSharp.Parse.Args) astFactory.create(Args)).add(argument_list_AST));
				currentAST.root = argument_list_AST;
				if ( (null != argument_list_AST) && (null != argument_list_AST.getFirstChild()) )
					currentAST.child = argument_list_AST.getFirstChild();
				else
					currentAST.child = argument_list_AST;
				currentAST.advanceChildToEnd();
			}
			argument_list_AST = currentAST.root;
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_19_);
			}
			else
			{
				throw;
			}
		}
		returnAST = argument_list_AST;
	}
	
	public void argument() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST argument_AST = null;
		AST ex_AST = null;
		AST dir_AST = null;
		AST vr_AST = null;
		
		try {      // for error handling
			switch ( LA(1) )
			{
			case IDENTIFIER:
			case INTEGER_LITERAL:
			case HEXADECIMAL_INTEGER_LITERAL:
			case REAL_LITERAL:
			case CHARACTER_LITERAL:
			case STRING_LITERAL:
			case TRUE:
			case FALSE:
			case NULL:
			case OBJECT:
			case STRING:
			case BOOL:
			case DECIMAL:
			case SBYTE:
			case BYTE:
			case SHORT:
			case USHORT:
			case INT:
			case UINT:
			case LONG:
			case ULONG:
			case CHAR:
			case FLOAT:
			case DOUBLE:
			case LPAREN:
			case THIS:
			case BASE:
			case INC:
			case DEC:
			case NEW:
			case TYPEOF:
			case CHECKED:
			case UNCHECKED:
			case PLUS:
			case MINUS:
			case LNOT:
			case BNOT:
			case STAR:
			case SIZEOF:
			{
				expression();
				if (0 == inputState.guessing)
				{
					ex_AST = (AST)returnAST;
				}
				if (0==inputState.guessing)
				{
					argument_AST = (AST)currentAST.root;
					argument_AST = 
							(AST)astFactory.make( (new ASTArray(2)).add((AST)astFactory.make( (new ASTArray(1)).add((DDW.CSharp.Parse.Arg) astFactory.create(Arg)))).add((AST)astFactory.make( (new ASTArray(2)).add((DDW.CSharp.Parse.Expression) astFactory.create(Expression)).add(ex_AST)))); 
						
					currentAST.root = argument_AST;
					if ( (null != argument_AST) && (null != argument_AST.getFirstChild()) )
						currentAST.child = argument_AST.getFirstChild();
					else
						currentAST.child = argument_AST;
					currentAST.advanceChildToEnd();
				}
				break;
			}
			case REF:
			case OUT:
			{
				parameter_direction();
				if (0 == inputState.guessing)
				{
					dir_AST = (AST)returnAST;
				}
				variable_reference();
				if (0 == inputState.guessing)
				{
					vr_AST = (AST)returnAST;
				}
				if (0==inputState.guessing)
				{
					argument_AST = (AST)currentAST.root;
					argument_AST = 
							(AST)astFactory.make( (new ASTArray(3)).add((AST)astFactory.make( (new ASTArray(1)).add((DDW.CSharp.Parse.Arg) astFactory.create(Arg)))).add(dir_AST).add((AST)astFactory.make( (new ASTArray(2)).add((DDW.CSharp.Parse.Expression) astFactory.create(Expression)).add(vr_AST)))); 
						
					currentAST.root = argument_AST;
					if ( (null != argument_AST) && (null != argument_AST.getFirstChild()) )
						currentAST.child = argument_AST.getFirstChild();
					else
						currentAST.child = argument_AST;
					currentAST.advanceChildToEnd();
				}
				break;
			}
			default:
			{
				throw new NoViableAltException(LT(1), getFilename());
			}
			 }
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex);
				consume();
				consumeUntil(tokenSet_14_);
			}
			else
			{
				throw;
			}
		}
		returnAST = argument_AST;
	}
	
	public void parameter_direction() //throws RecognitionException, TokenStreamException
{
		
		returnAST = null;
		ASTPair currentAST = new ASTPair();
		AST parameter_direction_AST = null;
		
		try {      // for error handling
			switch ( LA(1) )
			{
			case REF:
			{
				AST tmp27_AST = null;
				tmp27_AST = astFactory.create(LT(1));
				match(REF);
				if (0==inputState.guessing)
				{
					parameter_direction_AST = (AST)currentAST.root;
					parameter_direction_AST = (AST)astFactory.make( (new ASTArray(1)).add((DDW.CSharp.Parse.ArgDirection) astFactory.create(ArgDirection,"ref")));
					currentAST.root = parameter_direction_AST;
					if ( (null != parameter_direction_AST) && (null != parameter_direction_AST.getFirstChild()) )
						currentAST.child = parameter_direction_AST.getFirstChild();
					else
						currentAST.child = parameter_direction_AST;
					currentAST.advanceChildToEnd();
				}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -