44
55namespace WMDE \VueJsTemplating \JsParsing ;
66
7+ use Peast \Syntax \Node \BinaryExpression as PeastBinaryExpression ;
8+ use Peast \Syntax \Node \BooleanLiteral as PeastBooleanLiteral ;
79use Peast \Syntax \Node \CallExpression ;
810use Peast \Syntax \Node \Expression ;
911use Peast \Syntax \Node \Identifier ;
1012use Peast \Syntax \Node \MemberExpression ;
13+ use Peast \Syntax \Node \NumericLiteral as PeastNumericLiteral ;
1114use Peast \Syntax \Node \ObjectExpression ;
1215use Peast \Syntax \Node \StringLiteral as PeastStringLiteral ;
1316use Peast \Syntax \Node \UnaryExpression ;
@@ -71,6 +74,12 @@ protected function convertObjectExpression( ObjectExpression $expression ) {
7174 return new JsDictionary ( $ parsedExpressionMap );
7275 }
7376
77+ protected function convertBinaryExpression ( PeastBinaryExpression $ expression ) {
78+ $ lexp = $ this ->convertExpression ( $ expression ->getLeft () );
79+ $ rexp = $ this ->convertExpression ( $ expression ->getRight () );
80+ return new BinaryExpression ( $ lexp , $ rexp , $ expression ->getOperator () );
81+ }
82+
7483 public function convertExpression ( Expression $ expression ) {
7584 return match ( get_class ( $ expression ) ) {
7685 UnaryExpression::class => $ this ->convertUnaryExpression ( $ expression ),
@@ -79,6 +88,9 @@ public function convertExpression( Expression $expression ) {
7988 Identifier::class => new VariableAccess ( [ $ expression ->getName () ] ),
8089 CallExpression::class => $ this ->convertCallExpression ( $ expression ),
8190 ObjectExpression::class => $ this ->convertObjectExpression ( $ expression ),
91+ PeastBooleanLiteral::class => new BooleanLiteral ( $ expression ->getValue () ),
92+ PeastNumericLiteral::class => new NumericLiteral ( $ expression ->getValue () ),
93+ PeastBinaryExpression::class => $ this ->convertBinaryExpression ( $ expression ),
8294 default => throw new RuntimeException (
8395 'Unable to parse complex expression of type ' . get_class ( $ expression )
8496 )
0 commit comments