本文整理汇总了C#中Antlr3.Grammars.ActionTranslator.TranslateToChunks方法的典型用法代码示例。如果您正苦于以下问题:C# ActionTranslator.TranslateToChunks方法的具体用法?C# ActionTranslator.TranslateToChunks怎么用?C# ActionTranslator.TranslateToChunks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr3.Grammars.ActionTranslator
的用法示例。
在下文中一共展示了ActionTranslator.TranslateToChunks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TranslateArgAction
/** Translate an action like [3,"foo",a[3]] and return a List of the
* translated actions. Because actions are themselves translated to a list
* of chunks, must cat together into a StringTemplate>. Don't translate
* to strings early as we need to eval templates in context.
*/
public virtual List<StringTemplate> TranslateArgAction( string ruleName,
GrammarAST actionTree )
{
string actionText = actionTree.Token.Text;
List<string> args = GetListOfArgumentsFromAction( actionText, ',' );
List<StringTemplate> translatedArgs = new List<StringTemplate>();
foreach ( string arg in args )
{
if ( arg != null )
{
IToken actionToken =
new CommonToken( ANTLRParser.ACTION, arg );
ActionTranslator translator =
new ActionTranslator( this, ruleName,
actionToken,
actionTree.outerAltNum );
IList chunks = translator.TranslateToChunks();
chunks = target.PostProcessAction( chunks, actionToken );
StringTemplate catST = new StringTemplate( templates, "<chunks>" );
catST.SetAttribute( "chunks", chunks );
templates.CreateStringTemplate();
translatedArgs.Add( catST );
}
}
if ( translatedArgs.Count == 0 )
{
return null;
}
return translatedArgs;
}
示例2: TranslateAction
public IList TranslateAction( string action )
{
string rname = null;
if ( enclosingRule != null )
{
rname = enclosingRule.Name;
}
ActionTranslator translator =
new ActionTranslator( generator,
rname,
new CommonToken( ANTLRParser.ACTION, action ), outerAltNum );
return translator.TranslateToChunks();
}
示例3: TranslateAction
public virtual IList TranslateAction( string ruleName,
GrammarAST actionTree )
{
if ( actionTree.Type == ANTLRParser.ARG_ACTION )
{
return TranslateArgAction( ruleName, actionTree );
}
ActionTranslator translator = new ActionTranslator( this, ruleName, actionTree );
IList chunks = translator.TranslateToChunks();
chunks = target.PostProcessAction( chunks, actionTree.Token );
return chunks;
}