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


C# VBAParser类代码示例

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


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


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