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


C# ActionTranslator.TranslateToChunks方法代码示例

本文整理汇总了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;
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:35,代码来源:CodeGenerator.cs

示例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();
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:13,代码来源:ActionTranslatorHelper.cs

示例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;
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:12,代码来源:CodeGenerator.cs


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