当前位置: 首页>>代码示例>>C#>>正文


C# StringTemplate.setName方法代码示例

本文整理汇总了C#中StringTemplate.setName方法的典型用法代码示例。如果您正苦于以下问题:C# StringTemplate.setName方法的具体用法?C# StringTemplate.setName怎么用?C# StringTemplate.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringTemplate的用法示例。


在下文中一共展示了StringTemplate.setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: action

        //throws RecognitionException, TokenStreamException
        public void action(
		StringTemplate self
	)
        {
            IToken  a = null;
            IToken  i = null;

            try {      // for error handling
            switch ( LA(1) )
            {
            case ACTION:
            {
                a = LT(1);
                match(ACTION);

                String indent = ((ChunkToken)a).getIndentation();
                ASTExpr c = self.parseAction(a.getText());
                c.setIndentation(indent);
                self.addChunk(c);

                break;
            }
            case IF:
            {
                i = LT(1);
                match(IF);

                ConditionalExpr c = (ConditionalExpr)self.parseAction(i.getText());
                // create and precompile the subtemplate
                StringTemplate subtemplate =
                    new StringTemplate(self.getGroup(), null);
                subtemplate.setEnclosingInstance(self);
                subtemplate.setName(i.getText()+" subtemplate");
                self.addChunk(c);

                template(subtemplate);
                if ( c!=null ) c.setSubtemplate(subtemplate);
                {
                    switch ( LA(1) )
                    {
                    case ELSE:
                    {
                        match(ELSE);

                        // create and precompile the subtemplate
                        StringTemplate elseSubtemplate =
                                new StringTemplate(self.getGroup(), null);
                        elseSubtemplate.setEnclosingInstance(self);
                        elseSubtemplate.setName("else subtemplate");

                        template(elseSubtemplate);
                        if ( c!=null ) c.setElseSubtemplate(elseSubtemplate);
                        break;
                    }
                    case ENDIF:
                    {
                        break;
                    }
                    default:
                    {
                        throw new NoViableAltException(LT(1), getFilename());
                    }
                     }
                }
                match(ENDIF);
                break;
            }
            default:
            {
                throw new NoViableAltException(LT(1), getFilename());
            }
             }
            }
            catch (RecognitionException ex)
            {
            reportError(ex);
            recover(ex,tokenSet_1_);
            }
        }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:80,代码来源:TemplateParser.cs

示例2: arg

        //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_);
            }
        }
开发者ID:david-mcneil,项目名称:stringtemplate,代码行数:52,代码来源:GroupParser.cs


注:本文中的StringTemplate.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。