Beispiel #1
0
	protected MacroStatement  macro_stmt() //throws RecognitionException, TokenStreamException
{
		MacroStatement returnValue;
		
		
				returnValue = null;
				MacroStatement macro = new MacroStatement();
				StatementModifier modifier = null;
				antlr.IToken id = null;
			
		
		try {      // for error handling
			id=macro_name();
			expression_list(macro.Arguments);
			{
				if ((LA(1)==COLON) && (LA(2)==INDENT||LA(2)==EOL||LA(2)==EOS))
				{
					{
						begin_with_doc(macro);
						macro_block(macro.Body.Statements);
						end(macro.Body);
						if (0==inputState.guessing)
						{
							macro.Annotate("compound" );
						}
					}
				}
				else if ((LA(1)==COLON) && (tokenSet_20_.member(LA(2)))) {
					macro_compound_stmt(macro.Body);
					if (0==inputState.guessing)
					{
						macro.Annotate("compound");
					}
				}
				else if ((tokenSet_21_.member(LA(1)))) {
					{
						{
							switch ( LA(1) )
							{
							case EOL:
							case EOS:
							{
								eos();
								break;
							}
							case IF:
							case UNLESS:
							case WHILE:
							{
								modifier=stmt_modifier();
								eos();
								if (0==inputState.guessing)
								{
									macro.Modifier = modifier;
								}
								break;
							}
							default:
							{
								throw new NoViableAltException(LT(1), getFilename());
							}
							 }
						}
						docstring(macro);
					}
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
			if (0==inputState.guessing)
			{
				
						macro.Name = id.getText();
						macro.LexicalInfo = ToLexicalInfo(id);
						
						returnValue = macro;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "macro_stmt");
				recover(ex,tokenSet_22_);
			}
			else
			{
				throw ex;
			}
		}
		return returnValue;
	}
Beispiel #2
0
        //throws RecognitionException, TokenStreamException
        protected MacroStatement macro_stmt()
        {
            MacroStatement returnValue;

            IToken  id = null;

                returnValue = null;
                MacroStatement macro = new MacroStatement();
                StatementModifier modifier = null;

            try {      // for error handling
            id = LT(1);
            match(ID);
            expression_list(macro.Arguments);
            {
                switch ( LA(1) )
                {
                case COLON:
                {
                    compound_stmt(macro.Block);
                    if (0==inputState.guessing)
                    {
                        macro.Annotate("compound");
                    }
                    break;
                }
                case EOF:
                case EOS:
                case NEWLINE:
                {
                    eos();
                    break;
                }
                case IF:
                case UNLESS:
                case WHILE:
                {
                    modifier=stmt_modifier();
                    eos();
                    if (0==inputState.guessing)
                    {
                        macro.Modifier = modifier;
                    }
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            if (0==inputState.guessing)
            {

                        macro.Name = id.getText();
                        macro.LexicalInfo = SourceLocationFactory.ToLexicalInfo(id);

                        returnValue = macro;

            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_67_);
            }
            else
            {
                throw ex;
            }
            }
            return returnValue;
        }