Skip to content

Commit 9bea200

Browse files
committed
Pull with conflicts
2 parents be13ba7 + dd8f43e commit 9bea200

15 files changed

+165
-146
lines changed

RetailCoder.VBE/API/ParserState.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
using Rubberduck.Common;
77
using Rubberduck.Parsing.VBA;
88
using Rubberduck.UI.Command.MenuItems;
9+
using Rubberduck.Parsing.Preprocessing;
10+
using System.Globalization;
911

1012
namespace Rubberduck.API
1113
{
@@ -44,15 +46,13 @@ public sealed class ParserState : IParserState, IDisposable
4446
private const string ProgId = "Rubberduck.ParserState";
4547

4648
private readonly RubberduckParserState _state;
47-
private readonly AttributeParser _attributeParser;
48-
49+
private AttributeParser _attributeParser;
4950
private RubberduckParser _parser;
5051

5152
public ParserState()
5253
{
5354
UiDispatcher.Initialize();
5455
_state = new RubberduckParserState();
55-
_attributeParser = new AttributeParser(new ModuleExporter());
5656

5757
_state.StateChanged += _state_StateChanged;
5858
}
@@ -63,8 +63,9 @@ public void Initialize(VBE vbe)
6363
{
6464
throw new InvalidOperationException("ParserState is already initialized.");
6565
}
66-
67-
_parser = new RubberduckParser(vbe, _state, _attributeParser);
66+
Func<IVBAPreprocessor> preprocessorFactory = () => new VBAPreprocessor(double.Parse(vbe.Version, CultureInfo.InvariantCulture));
67+
_attributeParser = new AttributeParser(new ModuleExporter(), preprocessorFactory);
68+
_parser = new RubberduckParser(vbe, _state, _attributeParser, preprocessorFactory);
6869
}
6970

7071
/// <summary>

RetailCoder.VBE/Root/RubberduckModule.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
using Rubberduck.UnitTesting;
3434
using Rubberduck.VBEditor.VBEHost;
3535
using NLog;
36+
using Rubberduck.Parsing.Preprocessing;
37+
using System.Globalization;
3638

3739
namespace Rubberduck.Root
3840
{
@@ -94,6 +96,7 @@ public override void Load()
9496

9597
//Bind<TestExplorerModel>().To<StandardModuleTestExplorerModel>().InSingletonScope();
9698
Rebind<IRubberduckParser>().To<RubberduckParser>().InSingletonScope();
99+
Bind<Func<IVBAPreprocessor>>().ToMethod(p => () => new VBAPreprocessor(double.Parse(_vbe.Version, CultureInfo.InvariantCulture)));
97100

98101
_kernel.Rebind<ISearchResultsWindowViewModel>().To<SearchResultsWindowViewModel>().InSingletonScope();
99102
_kernel.Bind<SearchResultPresenterInstanceManager>().ToSelf().InSingletonScope();

Rubberduck.Parsing/Grammar/VBAParser.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,8 @@ public AttributeStmtContext attributeStmt() {
831831
}
832832

833833
public partial class AttributeNameContext : ParserRuleContext {
834-
public UnrestrictedIdentifierContext unrestrictedIdentifier() {
835-
return GetRuleContext<UnrestrictedIdentifierContext>(0);
834+
public LExpressionContext lExpression() {
835+
return GetRuleContext<LExpressionContext>(0);
836836
}
837837
public AttributeNameContext(ParserRuleContext parent, int invokingState)
838838
: base(parent, invokingState)
@@ -861,7 +861,7 @@ public AttributeNameContext attributeName() {
861861
try {
862862
EnterOuterAlt(_localctx, 1);
863863
{
864-
State = 499; unrestrictedIdentifier();
864+
State = 499; lExpression(0);
865865
}
866866
}
867867
catch (RecognitionException re) {
@@ -876,8 +876,8 @@ public AttributeNameContext attributeName() {
876876
}
877877

878878
public partial class AttributeValueContext : ParserRuleContext {
879-
public LiteralExpressionContext literalExpression() {
880-
return GetRuleContext<LiteralExpressionContext>(0);
879+
public ExpressionContext expression() {
880+
return GetRuleContext<ExpressionContext>(0);
881881
}
882882
public AttributeValueContext(ParserRuleContext parent, int invokingState)
883883
: base(parent, invokingState)
@@ -906,7 +906,7 @@ public AttributeValueContext attributeValue() {
906906
try {
907907
EnterOuterAlt(_localctx, 1);
908908
{
909-
State = 501; literalExpression();
909+
State = 501; expression(0);
910910
}
911911
}
912912
catch (RecognitionException re) {
@@ -18325,7 +18325,7 @@ private bool upperCaseA_sempred(UpperCaseAContext _localctx, int predIndex) {
1832518325
"\x3\x2\x2\x2\x1ED\x1EE\x3\x2\x2\x2\x1EE\x1EF\x3\x2\x2\x2\x1EF\x1F1\x5"+
1832618326
"\x12\n\x2\x1F0\x1E9\x3\x2\x2\x2\x1F1\x1F4\x3\x2\x2\x2\x1F2\x1F0\x3\x2"+
1832718327
"\x2\x2\x1F2\x1F3\x3\x2\x2\x2\x1F3\xF\x3\x2\x2\x2\x1F4\x1F2\x3\x2\x2\x2"+
18328-
"\x1F5\x1F6\x5\x126\x94\x2\x1F6\x11\x3\x2\x2\x2\x1F7\x1F8\x5\x150\xA9\x2"+
18328+
"\x1F5\x1F6\x5\x15A\xAE\x2\x1F6\x11\x3\x2\x2\x2\x1F7\x1F8\x5\x14E\xA8\x2"+
1832918329
"\x1F8\x13\x3\x2\x2\x2\x1F9\x1FA\x5\x18\r\x2\x1FA\x1FB\x5\x17C\xBF\x2\x1FB"+
1833018330
"\x1FD\x3\x2\x2\x2\x1FC\x1F9\x3\x2\x2\x2\x1FD\x200\x3\x2\x2\x2\x1FE\x1FC"+
1833118331
"\x3\x2\x2\x2\x1FE\x1FF\x3\x2\x2\x2\x1FF\x15\x3\x2\x2\x2\x200\x1FE\x3\x2"+

Rubberduck.Parsing/Grammar/VBAParser.g4

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ moduleConfigElement :
4747

4848
moduleAttributes : (attributeStmt endOfStatement)*;
4949
attributeStmt : ATTRIBUTE whiteSpace attributeName whiteSpace? EQ whiteSpace? attributeValue (whiteSpace? COMMA whiteSpace? attributeValue)*;
50-
attributeName : unrestrictedIdentifier;
51-
attributeValue : literalExpression;
50+
attributeName : lExpression;
51+
attributeValue : expression;
5252

5353
moduleDeclarations : (moduleDeclarationsElement endOfStatement)*;
5454

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Rubberduck.Parsing.Preprocessing
2+
{
3+
public interface IVBAPreprocessor
4+
{
5+
string Execute(string moduleName, string unprocessedCode);
6+
}
7+
}

Rubberduck.Parsing/Preprocessing/VBAPreprocessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Rubberduck.Parsing.Preprocessing
44
{
5-
public sealed class VBAPreprocessor
5+
public sealed class VBAPreprocessor : IVBAPreprocessor
66
{
77
private readonly double _vbaVersion;
88
private readonly VBAPrecompilationParser _parser;

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
<Compile Include="Grammar\VBAParserBaseVisitor.cs" />
121121
<Compile Include="Grammar\VBAParserListener.cs" />
122122
<Compile Include="Grammar\VBAParserVisitor.cs" />
123+
<Compile Include="Preprocessing\IVBAPreprocessor.cs" />
123124
<Compile Include="Preprocessing\VBAConditionalCompilationParser.cs" />
124125
<Compile Include="Preprocessing\VBAConditionalCompilationParserBaseListener.cs" />
125126
<Compile Include="Preprocessing\VBAConditionalCompilationParserBaseVisitor.cs" />

Rubberduck.Parsing/Symbols/DeclarationFinder.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using Rubberduck.VBEditor;
55
using System;
66
using System.Collections.Generic;
7-
using System.Diagnostics;
87
using System.Linq;
98

109
namespace Rubberduck.Parsing.Symbols

0 commit comments

Comments
 (0)