Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ternary not supported #7

Open
L2jLiga opened this issue Jul 18, 2024 · 3 comments
Open

ternary not supported #7

L2jLiga opened this issue Jul 18, 2024 · 3 comments

Comments

@L2jLiga
Copy link
Contributor

L2jLiga commented Jul 18, 2024

Hello, I've noticed that parser unable to work with ternary expression, could you fix this please?

input:

$variable=$true ?1:0

output:

(program [0, 0] - [0, 19]
  (statement_list [0, 0] - [0, 19]
    (pipeline [0, 0] - [0, 19]
      (assignment_expression [0, 0] - [0, 19]
        (left_assignment_expression [0, 0] - [0, 9]
          (logical_expression [0, 0] - [0, 9]
            (bitwise_expression [0, 0] - [0, 9]
              (comparison_expression [0, 0] - [0, 9]
                (additive_expression [0, 0] - [0, 9]
                  (multiplicative_expression [0, 0] - [0, 9]
                    (format_expression [0, 0] - [0, 9]
                      (range_expression [0, 0] - [0, 9]
                        (array_literal_expression [0, 0] - [0, 9]
                          (unary_expression [0, 0] - [0, 9]
                            (variable [0, 0] - [0, 9])))))))))))
        (assignement_operator [0, 9] - [0, 10])
        (ERROR [0, 10] - [0, 16]
          (variable [0, 10] - [0, 15])
          (ERROR [0, 15] - [0, 16]))
        value: (pipeline [0, 16] - [0, 19]
          (command [0, 16] - [0, 19]
            command_name: (command_name [0, 16] - [0, 19])))))))
@citronneur
Copy link
Member

As far as I know there is no ternary operator in powershell

@citronneur
Copy link
Member

Thanks @ZeArioch to point me the documentation : https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_if?view=powershell-7.4#using-the-ternary-operator-syntax

The example you provide is not supported by Powershell, only ternary operator is allowed following a parenthesis expression... Ok I will try to fix this issue. Thanks @L2jLiga !

@L2jLiga
Copy link
Contributor Author

L2jLiga commented Jul 30, 2024

Thanks @ZeArioch to point me the documentation : https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_if?view=powershell-7.4#using-the-ternary-operator-syntax

Sorry, I totally forgot to provide link to the documentation 😅

The example you provide is not supported by Powershell, only ternary operator is allowed following a parenthesis expression... Ok I will try to fix this issue. Thanks @L2jLiga !

That's actually weird because I've checked provided example in powershell 7.4.4 on Windows 11 in Windows Terminal:

┏[ user from  DESKTOP-JRVT494][ 0.196s][kubernetes-super-admin@kubernetes]
┖[~]
└─Δ $variable=$true ?1:0
┏[ user from  DESKTOP-JRVT494][ 0s][kubernetes-super-admin@kubernetes]
┖[~]
└─Δ echo $variable
1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants