本文整理汇总了C#中StringTemplate.setEnclosingInstance方法的典型用法代码示例。如果您正苦于以下问题:C# StringTemplate.setEnclosingInstance方法的具体用法?C# StringTemplate.setEnclosingInstance怎么用?C# StringTemplate.setEnclosingInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringTemplate
的用法示例。
在下文中一共展示了StringTemplate.setEnclosingInstance方法的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_);
}
}
示例2: anonymousTemplate
//throws RecognitionException, TokenStreamException
public void anonymousTemplate()
{
returnAST = null;
ASTPair currentAST = ASTPair.GetInstance();
antlr.stringtemplate.language.StringTemplateAST anonymousTemplate_AST = null;
IToken t = null;
antlr.stringtemplate.language.StringTemplateAST t_AST = null;
try { // for error handling
t = LT(1);
t_AST = (antlr.stringtemplate.language.StringTemplateAST) astFactory.create(t);
astFactory.addASTChild(currentAST, (AST)t_AST);
match(ANONYMOUS_TEMPLATE);
if (0==inputState.guessing)
{
StringTemplate anonymous = new StringTemplate();
anonymous.setGroup(self.getGroup());
anonymous.setEnclosingInstance(self);
anonymous.setTemplate(t.getText());
t_AST.setStringTemplate(anonymous);
}
anonymousTemplate_AST = (antlr.stringtemplate.language.StringTemplateAST)currentAST.root;
}
catch (RecognitionException ex)
{
if (0 == inputState.guessing)
{
reportError(ex);
recover(ex,tokenSet_3_);
}
else
{
throw ex;
}
}
returnAST = anonymousTemplate_AST;
ASTPair.PutInstance(currentAST);
}