File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed
src/Domain/HydraScript.Domain.FrontEnd/Parser/Impl Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change 1+ using HydraScript . Domain . FrontEnd . Parser . Impl . Ast . Nodes . Expressions . ComplexLiterals ;
2+
3+ namespace HydraScript . Domain . FrontEnd . Parser . Impl . Ast . Nodes . Expressions ;
4+
5+ [ AutoVisitable < IAbstractSyntaxTreeNode > ]
6+ public partial class WithExpression : Expression
7+ {
8+ protected override IReadOnlyList < IAbstractSyntaxTreeNode > Children { get ; }
9+
10+ public Expression Expression { get ; }
11+ public ObjectLiteral ObjectLiteral { get ; }
12+
13+ public WithExpression ( Expression expression , ObjectLiteral objectLiteral )
14+ {
15+ Expression = expression ;
16+ Expression . Parent = this ;
17+
18+ ObjectLiteral = objectLiteral ;
19+ ObjectLiteral . Parent = this ;
20+
21+ Children = [ Expression , ObjectLiteral ] ;
22+ }
23+
24+ protected override string NodeRepresentation ( ) => "with" ;
25+ }
Original file line number Diff line number Diff line change @@ -541,16 +541,32 @@ private Expression MemberExpression()
541541 }
542542
543543 /// <summary>
544- /// CastExpression -> ConditionalExpression 'as' 'string'
544+ /// CastExpression -> WithExpression 'as' 'string'
545545 /// </summary>
546546 private Expression CastExpression ( )
547547 {
548- var cond = ConditionalExpression ( ) ;
548+ var withExpr = WithExpression ( ) ;
549549 if ( CurrentIsKeyword ( "as" ) )
550550 {
551551 var asKeyword = Expect ( "Keyword" , "as" ) ;
552552 var type = TypeValue ( ) ;
553- return new CastAsExpression ( cond , type ) { Segment = asKeyword . Segment } ;
553+ return new CastAsExpression ( withExpr , type ) { Segment = asKeyword . Segment } ;
554+ }
555+
556+ return withExpr ;
557+ }
558+
559+ /// <summary>
560+ /// WithExpression -> ConditionalExpression 'with' ObjectLiteral
561+ /// </summary>
562+ private Expression WithExpression ( )
563+ {
564+ var cond = ConditionalExpression ( ) ;
565+ if ( CurrentIsKeyword ( "with" ) )
566+ {
567+ var withKeyword = Expect ( "Keyword" , "with" ) ;
568+ var objectLiteral = ObjectLiteral ( ) ;
569+ return new WithExpression ( cond , objectLiteral ) { Segment = withKeyword . Segment } ;
554570 }
555571
556572 return cond ;
You can’t perform that action at this time.
0 commit comments