Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
129 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Antlr4.Runtime; | ||
using Antlr4.Runtime.Tree; | ||
using NLog; | ||
using Rubberduck.Parsing.Symbols; | ||
|
||
namespace Rubberduck.Parsing.Binding | ||
{ | ||
public abstract class BindingContextBase : IBindingContext | ||
{ | ||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); | ||
|
||
|
||
|
||
protected IExpressionBinding HandleUnexpectedExpressionType(ParserRuleContext expression) | ||
{ | ||
Logger.Warn($"Unexpected context type {expression.GetType()}"); | ||
return new FailedExpressionBinding(expression); | ||
} | ||
|
||
public abstract IBoundExpression Resolve(Declaration module, | ||
Declaration parent, | ||
ParserRuleContext expression, | ||
IBoundExpression withBlockVariable, | ||
StatementResolutionContext statementContext, | ||
bool requiresLetCoercion = false, | ||
bool isLetAssignment = false); | ||
|
||
public abstract IExpressionBinding BuildTree(Declaration module, | ||
Declaration parent, | ||
ParserRuleContext expression, | ||
IBoundExpression withBlockVariable, | ||
StatementResolutionContext statementContext, | ||
bool requiresLetCoercion = false, | ||
bool isLetAssignment = false); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Rubberduck.Parsing/Binding/Bindings/FailedExpressionBinding.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Antlr4.Runtime; | ||
|
||
namespace Rubberduck.Parsing.Binding | ||
{ | ||
public sealed class FailedExpressionBinding : IExpressionBinding | ||
{ | ||
private readonly ParserRuleContext _context; | ||
|
||
public FailedExpressionBinding(ParserRuleContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public IBoundExpression Resolve() | ||
{ | ||
return new ResolutionFailedExpression(_context); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,25 @@ | ||
using Antlr4.Runtime.Tree; | ||
using Antlr4.Runtime; | ||
using Rubberduck.Parsing.Symbols; | ||
|
||
namespace Rubberduck.Parsing.Binding | ||
{ | ||
public interface IBindingContext | ||
{ | ||
IBoundExpression Resolve(Declaration module, Declaration parent, IParseTree expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext, bool requiresLetCoercion = false, bool isLetAssignment = false); | ||
IExpressionBinding BuildTree(Declaration module, Declaration parent, IParseTree expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext, bool requiresLetCoercion = false, bool isLetAssignment = false); | ||
IBoundExpression Resolve( | ||
Declaration module, | ||
Declaration parent, | ||
ParserRuleContext expression, | ||
IBoundExpression withBlockVariable, | ||
StatementResolutionContext statementContext, | ||
bool requiresLetCoercion = false, | ||
bool isLetAssignment = false); | ||
IExpressionBinding BuildTree( | ||
Declaration module, | ||
Declaration parent, | ||
ParserRuleContext expression, | ||
IBoundExpression withBlockVariable, | ||
StatementResolutionContext statementContext, | ||
bool requiresLetCoercion = false, | ||
bool isLetAssignment = false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters