1
1
using System . Linq . Expressions ;
2
+ using Hyperbee . Collections ;
2
3
using Parlot ;
3
4
using Parlot . Fluent ;
4
5
5
6
namespace Hyperbee . XS . Parsers ;
6
7
7
8
internal class ValueIdentifierParser : Parser < Expression >
8
9
{
9
- private readonly ParseScope _scope ;
10
+ private readonly LinkedDictionary < string , ParameterExpression > _variables ;
10
11
11
- public ValueIdentifierParser ( ParseScope scope )
12
+ public ValueIdentifierParser ( LinkedDictionary < string , ParameterExpression > variables )
12
13
{
13
- _scope = scope ;
14
+ _variables = variables ;
14
15
}
15
16
16
17
public override bool Parse ( ParseContext context , ref ParseResult < Expression > result )
@@ -25,7 +26,7 @@ public override bool Parse( ParseContext context, ref ParseResult<Expression> re
25
26
26
27
if ( scanner . ReadIdentifier ( out var identifier ) )
27
28
{
28
- if ( _scope . TryLookupVariable ( identifier . ToString ( ) , out var variable ) )
29
+ if ( _variables . TryGetValue ( identifier . ToString ( ) , out var variable ) )
29
30
{
30
31
result . Set ( start . Offset , cursor . Position . Offset , variable ) ;
31
32
context . ExitParser ( this ) ;
@@ -41,9 +42,9 @@ public override bool Parse( ParseContext context, ref ParseResult<Expression> re
41
42
42
43
internal static partial class XsParsers
43
44
{
44
- public static Parser < Expression > ValueIdentifier ( ParseScope scope )
45
+ public static Parser < Expression > ValueIdentifier ( LinkedDictionary < string , ParameterExpression > variables )
45
46
{
46
- return new ValueIdentifierParser ( scope ) ;
47
+ return new ValueIdentifierParser ( variables ) ;
47
48
}
48
49
}
49
50
0 commit comments