Skip to content

Commit 776661c

Browse files
committed
clean up value-identifier-parser
1 parent b84f282 commit 776661c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Hyperbee.ExpressionScript/Parsers/ValueIdentifierParser.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
using System.Linq.Expressions;
2+
using Hyperbee.Collections;
23
using Parlot;
34
using Parlot.Fluent;
45

56
namespace Hyperbee.XS.Parsers;
67

78
internal class ValueIdentifierParser : Parser<Expression>
89
{
9-
private readonly ParseScope _scope;
10+
private readonly LinkedDictionary<string, ParameterExpression> _variables;
1011

11-
public ValueIdentifierParser( ParseScope scope )
12+
public ValueIdentifierParser( LinkedDictionary<string, ParameterExpression> variables )
1213
{
13-
_scope = scope;
14+
_variables = variables;
1415
}
1516

1617
public override bool Parse( ParseContext context, ref ParseResult<Expression> result )
@@ -25,7 +26,7 @@ public override bool Parse( ParseContext context, ref ParseResult<Expression> re
2526

2627
if ( scanner.ReadIdentifier( out var identifier ) )
2728
{
28-
if ( _scope.TryLookupVariable( identifier.ToString(), out var variable ) )
29+
if ( _variables.TryGetValue( identifier.ToString(), out var variable ) )
2930
{
3031
result.Set( start.Offset, cursor.Position.Offset, variable );
3132
context.ExitParser( this );
@@ -41,9 +42,9 @@ public override bool Parse( ParseContext context, ref ParseResult<Expression> re
4142

4243
internal static partial class XsParsers
4344
{
44-
public static Parser<Expression> ValueIdentifier( ParseScope scope )
45+
public static Parser<Expression> ValueIdentifier( LinkedDictionary<string, ParameterExpression> variables )
4546
{
46-
return new ValueIdentifierParser( scope );
47+
return new ValueIdentifierParser( variables );
4748
}
4849
}
4950

src/Hyperbee.ExpressionScript/XsParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ private Parser<Expression> ExpressionParser( Deferred<Expression> statement )
232232

233233
// Identifiers
234234

235-
var valueIdentifier = XsParsers.ValueIdentifier( Scope );
235+
var valueIdentifier = XsParsers.ValueIdentifier( Scope.Variables );
236236
var typeIdentifier = XsParsers.TypeIdentifier( Resolver );
237237

238238
var identifier = OneOf(

0 commit comments

Comments
 (0)