Пример #1
0
        //throws RecognitionException, TokenStreamException
        public void args(
		StringTemplate st
	)
        {
            IToken  name = null;
            IToken  name2 = null;

            try {      // for error handling
            name = LT(1);
            match(ID);
            st.defineFormalArgument(name.getText());
            {    // ( ... )*
                for (;;)
                {
                    if ((LA(1)==COMMA))
                    {
                        match(COMMA);
                        name2 = LT(1);
                        match(ID);
                        st.defineFormalArgument(name2.getText());
                    }
                    else
                    {
                        goto _loop8_breakloop;
                    }

                }
            _loop8_breakloop:				;
            }    // ( ... )*
            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_2_);
            }
        }
Пример #2
0
        //throws RecognitionException, TokenStreamException
        public void arg(
		StringTemplate st
	)
        {
            IToken  name = null;
            IToken  s = null;
            IToken  bs = null;

            StringTemplate defaultValue = null;

            try {      // for error handling
            name = LT(1);
            match(ID);
            {
                if ((LA(1)==ASSIGN) && (LA(2)==STRING))
                {
                    match(ASSIGN);
                    s = LT(1);
                    match(STRING);

                                defaultValue=new StringTemplate("$_val_$");
                                defaultValue.setAttribute("_val_", s.getText());
                                defaultValue.defineFormalArgument("_val_");
                                defaultValue.setName("<"+st.getName()+"'s arg "+name.getText()+" default value subtemplate>");

                }
                else if ((LA(1)==ASSIGN) && (LA(2)==ANONYMOUS_TEMPLATE)) {
                    match(ASSIGN);
                    bs = LT(1);
                    match(ANONYMOUS_TEMPLATE);

                                defaultValue=new StringTemplate(st.getGroup(), bs.getText());
                                defaultValue.setName("<"+st.getName()+"'s arg "+name.getText()+" default value subtemplate>");

                }
                else if ((LA(1)==RPAREN||LA(1)==COMMA)) {
                }
                else
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }

            }
            st.defineFormalArgument(name.getText(), defaultValue);
            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_3_);
            }
        }