• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# VBAParser类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中VBAParser的典型用法代码示例。如果您正苦于以下问题:C# VBAParser类的具体用法?C# VBAParser怎么用?C# VBAParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VBAParser类属于命名空间,在下文中一共展示了VBAParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ProcedureNode

 public ProcedureNode(VBAParser.SubStmtContext context, string scope, string localScope)
     : this(context, scope, localScope, VBProcedureKind.Sub, context.visibility(), context.ambiguousIdentifier(), null)
 {
     _argsListContext = context.argList();
     _staticNode = context.STATIC();
     _keyword = context.SUB();
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:ProcedureNode.cs


示例2: Parse

        /// <summary>
        /// Exports the specified component to a temporary file, loads, and then parses the exported file.
        /// </summary>
        /// <param name="component"></param>
        public IDictionary<Tuple<string, DeclarationType>, Attributes> Parse(VBComponent component)
        {
            var path = _exporter.Export(component);
            if (!File.Exists(path))
            {
                // a document component without any code wouldn't be exported (file would be empty anyway).
                return new Dictionary<Tuple<string, DeclarationType>, Attributes>();
            }

            var code = File.ReadAllText(path);
            File.Delete(path);

            var type = component.Type == vbext_ComponentType.vbext_ct_StdModule
                ? DeclarationType.Module
                : DeclarationType.Class;
            var listener = new AttributeListener(Tuple.Create(component.Name, type));

            var stream = new AntlrInputStream(code);
            var lexer = new VBALexer(stream);
            var tokens = new CommonTokenStream(lexer);
            var parser = new VBAParser(tokens);

            // parse tree isn't usable for declarations because
            // line numbers are offset due to module header and attributes
            // (these don't show up in the VBE, that's why we're parsing an exported file)
            var tree = parser.startRule();
            ParseTreeWalker.Default.Walk(listener, tree);

            return listener.Attributes;
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:34,代码来源:AttributeParser.cs


示例3: ParsesEmptyForm

        public void ParsesEmptyForm()
        {
            var code = @"
VERSION 5.00
Begin {C62A69F0-16DC-11CE-9E98-00AA00574A4F} Form1 
   Caption         =   ""Form1""
   ClientHeight    =   2640
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   4710
   OleObjectBlob   =   ""Form1.frx"":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = ""Form1""
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
";
            var stream = new AntlrInputStream(code);
            var lexer = new VBALexer(stream);
            var tokens = new CommonTokenStream(lexer);
            var parser = new VBAParser(tokens);
            parser.ErrorListeners.Clear();
            parser.ErrorListeners.Add(new ExceptionErrorListener());
            var tree = parser.startRule();
            Assert.IsNotNull(tree);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:28,代码来源:VBAParserTests.cs


示例4: EnterICS_S_VariableOrProcedureCall

 public override void EnterICS_S_VariableOrProcedureCall(VBAParser.ICS_S_VariableOrProcedureCallContext context)
 {
     if (context.Parent.GetType() != typeof (VBAParser.ICS_S_MemberCallContext))
     {
         _resolver.Resolve(context);
     }
 }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:7,代码来源:IdentifierReferenceListener.cs


示例5: GetProcedureAccessibility

        /// <summary>
        /// Gets the <c>Accessibility</c> for a procedure member.
        /// </summary>
        private Accessibility GetProcedureAccessibility(VBAParser.VisibilityContext visibilityContext)
        {
            var visibility = visibilityContext == null
                ? "Implicit" // "Public"
                : visibilityContext.GetText();

            return (Accessibility)Enum.Parse(typeof(Accessibility), visibility);
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:11,代码来源:DeclarationSymbolsListener.cs


示例6: HasExplicitCallStatement

 private bool HasExplicitCallStatement(VBAParser.ECS_ProcedureCallContext call)
 {
     if (call == null)
     {
         return false;
     }
     var statement = call.CALL();
     return statement != null && statement.Symbol.Text == Tokens.Call;
 }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:9,代码来源:IdentifierReference.cs


示例7: GetNode

        private ProcedureNode GetNode(VBAParser.PropertyGetStmtContext context)
        {
            if (context == null)
            {
                return null;
            }

            var scope = Selection.QualifiedName.ToString();
            var localScope = scope + "." + context.ambiguousIdentifier().GetText();
            return new ProcedureNode(context, scope, localScope);
        }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:11,代码来源:ImplicitVariantReturnTypeInspectionResult.cs


示例8: DeclareExplicitVariant

        private string DeclareExplicitVariant(VBAParser.ArgContext context, out string instruction)
        {
            if (context == null)
            {
                instruction = null;
                return null;
            }

            instruction = context.GetText();
            return instruction + ' ' + Tokens.As + ' ' + Tokens.Variant;
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:11,代码来源:VariableTypeNotDeclaredInspectionResult.cs


示例9: Create

 public IAnnotation Create(VBAParser.AnnotationContext context, QualifiedSelection qualifiedSelection)
 {
     string annotationName = context.annotationName().GetText();
     List<string> parameters = new List<string>();
     var argList = context.annotationArgList();
     if (argList != null)
     {
         parameters.AddRange(argList.annotationArg().Select(arg => arg.GetText()));
     }
     Type annotationCLRType = null;
     if (_creators.TryGetValue(annotationName.ToUpperInvariant(), out annotationCLRType))
     {
         return (IAnnotation)Activator.CreateInstance(annotationCLRType, qualifiedSelection, parameters);
     }
     return null;
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:16,代码来源:VBAParserAnnotationFactory.cs


示例10: Parse

        public IParseTree Parse(string code, out ITokenStream outStream)
        {
            var input = new AntlrInputStream(code);
            var lexer = new VBALexer(input);
            var tokens = new CommonTokenStream(lexer);
            var parser = new VBAParser(tokens);
            parser.AddErrorListener(new ExceptionErrorListener());
            outStream = tokens;

            var result = parser.startRule();
            return result;
        }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:12,代码来源:RubberduckParser.cs


示例11: EnterAmbiguousIdentifier

            public override void EnterAmbiguousIdentifier(VBAParser.AmbiguousIdentifierContext context)
            {
                DeclarationType type;
                if (!ScopingContextTypes.TryGetValue(context.Parent.GetType(), out type))
                {
                    return;
                }

                _currentScope = Tuple.Create(context.GetText(), type);
            }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:10,代码来源:AttributeParser.cs


示例12: ExitModuleAttributes

 public override void ExitModuleAttributes(VBAParser.ModuleAttributesContext context)
 {
     _attributes.Add(_currentScope, _currentScopeAttributes);
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:4,代码来源:AttributeParser.cs


示例13: ExitModuleConfigElement

 public override void ExitModuleConfigElement(VBAParser.ModuleConfigElementContext context)
 {
     var name = context.ambiguousIdentifier().GetText();
     var literal = context.literal();
     var values = new[] { literal == null ? string.Empty : literal.GetText()};
     _currentScopeAttributes.Add(name, values);
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:AttributeParser.cs


示例14: ExitAttributeStmt

 public override void ExitAttributeStmt(VBAParser.AttributeStmtContext context)
 {
     var name = context.implicitCallStmt_InStmt().GetText().Trim();
     var values = context.literal().Select(e => e.GetText().Replace("\"", string.Empty)).ToList();
     _currentScopeAttributes.Add(name, values);
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:6,代码来源:AttributeParser.cs


示例15: ExitPropertySetStmt

 public override void ExitPropertySetStmt(VBAParser.PropertySetStmtContext context)
 {
     if (!string.IsNullOrEmpty(_currentScope.Item1) && _currentScopeAttributes.Any())
     {
         _attributes.Add(_currentScope, _currentScopeAttributes);
     }
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:AttributeParser.cs


示例16: EnterPropertySetStmt

 public override void EnterPropertySetStmt(VBAParser.PropertySetStmtContext context)
 {
     _currentScopeAttributes = new Attributes();
     _currentScope = Tuple.Create(context.ambiguousIdentifier().GetText(), DeclarationType.PropertySet);
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:5,代码来源:AttributeParser.cs


示例17: ExitArgList

 public override void ExitArgList(VBAParser.ArgListContext context)
 {
     if (context.arg() != null && context.arg().Count(a => a.BYREF() != null || (a.BYREF() == null && a.BYVAL() == null)) == 1)
     {
         _contexts.Add(context);
     }
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:7,代码来源:RubberduckParser.cs


示例18: ExitLiteral

 public override void ExitLiteral(VBAParser.LiteralContext context)
 {
     var literal = context.STRINGLITERAL();
     if (literal != null && literal.GetText() == "\"\"")
     {
         _contexts.Add(context);
     }
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:8,代码来源:RubberduckParser.cs


示例19: AssertTree

 private void AssertTree(VBAParser parser, ParserRuleContext root, string xpath)
 {
     AssertTree(parser, root, xpath, matches => matches.Count >= 1);
 }
开发者ID:retailcoder,项目名称:Rubberduck,代码行数:4,代码来源:VBAParserTests.cs


示例20: EnterWithStmt

 public override void EnterWithStmt(VBAParser.WithStmtContext context)
 {
     _resolver.EnterWithBlock(context);
 }
开发者ID:ThunderFrame,项目名称:Rubberduck,代码行数:4,代码来源:IdentifierReferenceListener.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# VBox类代码示例发布时间:2022-05-24
下一篇:
C# Utils.ProgressBlock类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap