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


C# Antlr3.Codegen.CodeGenerator.Write方法代码示例

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


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

示例1: GenRecognizerHeaderFile

 protected override void GenRecognizerHeaderFile( AntlrTool tool,
                                        CodeGenerator generator,
                                        Grammar grammar,
                                        StringTemplate headerFileST,
                                        string extName )
 {
     generator.Write( headerFileST, grammar.name + Grammar.grammarTypeToFileNameSuffix[(int)grammar.type] + extName );
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:8,代码来源:ObjCTarget.cs

示例2: GenRecognizerHeaderFile

 protected override void GenRecognizerHeaderFile( AntlrTool tool,
                                        CodeGenerator generator,
                                        Grammar grammar,
                                        StringTemplate headerFileST,
                                        string extName )
 {
     StringTemplateGroup templates = generator.Templates;
     generator.Write( headerFileST, grammar.name + extName );
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:9,代码来源:CPPTarget.cs

示例3: GenRecognizerFile

        protected override void GenRecognizerFile(AntlrTool tool, CodeGenerator generator, Grammar grammar, StringTemplate outputFileST)
        {
            /*
                Below is an experimental attempt at providing a few named action blocks
                that are printed in both lexer and parser files from combined grammars.
                ANTLR appears to first generate a parser, then generate an independent lexer,
                and then generate code from that. It keeps the combo/parser grammar object
                and the lexer grammar object, as well as their respective code generator and
                target instances, completely independent. So, while a bit hack-ish, this is
                a solution that should work without having to modify Terrence Parr's
                core tool code.

                - sharedActionBlocks is a class variable containing a hash map
                - if this method is called with a combo grammar, and the action map
                  in the grammar contains an entry for the named scope "all",
                  add an entry to sharedActionBlocks mapping the grammar name to
                  the "all" action map.
                - if this method is called with an `implicit lexer'
                  (one that's extracted from a combo grammar), check to see if
                  there's an entry in sharedActionBlocks for the lexer's grammar name.
                - if there is an action map entry, place it in the lexer's action map
                - the recognizerFile template has code to place the
                  "all" actions appropriately

                problems:
                  - This solution assumes that the parser will be generated
                    before the lexer. If that changes at some point, this will
                    not work.
                  - I have not investigated how this works with delegation yet

                Kyle Yetter - March 25, 2010
            */
            if (grammar.type == GrammarType.Combined)
            {
                IDictionary<string, object> all;
                if (grammar.Actions.TryGetValue("all", out all))
                    sharedActionBlocks[grammar.name] = all;
            }
            else if (grammar.implicitLexer)
            {
                IDictionary<string, object> shared;
                if (sharedActionBlocks.TryGetValue(grammar.name, out shared))
                    grammar.Actions["all"] = shared;
            }

            generator.Templates.RegisterRenderer(typeof(string), new RubyRenderer());
            string fileName = generator.GetRecognizerFileName(grammar.name, grammar.type);
            generator.Write(outputFileST, fileName);
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:49,代码来源:RubyTarget.cs

示例4: GenRecognizerHeaderFile

        protected override void GenRecognizerHeaderFile(AntlrTool tool,
                CodeGenerator generator,
                Grammar grammar,
                StringTemplate headerFileST,
                string extName)
        {
            //Its better we remove the EOF Token, as it would have been defined everywhere in C.
            //we define it later as "EOF_TOKEN" instead of "EOF"
            IList<object> tokens = (IList<object>)headerFileST.GetAttribute("tokens");
            for (int i = 0; i < tokens.Count; ++i)
            {
                bool can_break = false;
                object tok = tokens[i];
                if (tok is Aggregate)
                {
                    Aggregate atok = (Aggregate)tok;
                    foreach (var pair in atok.Properties)
                    {
                        if (pair.Value.Equals("EOF"))
                        {
                            tokens.RemoveAt(i);
                            can_break = true;
                            break;
                        }
                    }
                }

                if (can_break)
                    break;
            }

            // Pick up the file name we are generating. This method will return a
            // a file suffixed with .c, so we must substring and add the extName
            // to it as we cannot assign into strings in Java.
            ///
            string fileName = generator.GetRecognizerFileName(grammar.name, grammar.type);
            fileName = fileName.Substring(0, fileName.Length - 4) + extName;

            generator.Write(headerFileST, fileName);
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:40,代码来源:CPPTarget.cs

示例5: GenRecognizerFile

 protected override void GenRecognizerFile(AntlrTool tool,
         CodeGenerator generator,
         Grammar grammar,
         StringTemplate outputFileST)
 {
     // Before we write this, and cause it to generate its string,
     // we need to add all the string literals that we are going to match
     //
     outputFileST.Add("literals", strings);
     string fileName = generator.GetRecognizerFileName(grammar.name, grammar.type);
     generator.Write(outputFileST, fileName);
 }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:12,代码来源:CPPTarget.cs

示例6: GenRecognizerHeaderFile

        protected override void GenRecognizerHeaderFile( AntlrTool tool,
                                               CodeGenerator generator,
                                               Grammar grammar,
                                               StringTemplate headerFileST,
                                               string extName )
        {
            // Pick up the file name we are generating. This method will return a
            // a file suffixed with .c, so we must substring and add the extName
            // to it as we cannot assign into strings in Java.
            ///
            string fileName = generator.GetRecognizerFileName( grammar.name, grammar.type );
            fileName = fileName.Substring( 0, fileName.Length - 2 ) + extName;

            generator.Write( headerFileST, fileName );
        }
开发者ID:mahanteshck,项目名称:antlrcs,代码行数:15,代码来源:CTarget.cs

示例7: GenRecognizerFile

 protected override void GenRecognizerFile(AntlrTool tool, CodeGenerator generator, Grammar grammar, StringTemplate outputFileST)
 {
     generator.Templates.RegisterRenderer(typeof(string), new RubyRenderer());
     string fileName = generator.GetRecognizerFileName(grammar.name, grammar.type);
     generator.Write(outputFileST, fileName);
 }
开发者ID:bszafko,项目名称:antlrcs,代码行数:6,代码来源:RubyTarget.cs


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