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

Parameter expansion with :=, :-, etc #280

Open
k4leg opened this issue Dec 6, 2024 · 0 comments
Open

Parameter expansion with :=, :-, etc #280

k4leg opened this issue Dec 6, 2024 · 0 comments

Comments

@k4leg
Copy link

k4leg commented Dec 6, 2024

In some cases, tree-sitter treats a word as a concatenation of a variable and a word.

Syntax Tree
Bash
#!/usr/bin/env bash

: ${ASDF:=qwer-zxcv}
: ${ASDF:=qwer}
ASDF=${ASDF:-qwer-zxcv}
: ${ASDF:?qwer+zxcv}
: ${ASDF:?qwer#zxcv}
: ${ASDF:?qwer@zxcv}
: ${ASDF:?qwer=zxcv}
: ${ASDF:+qwer-asdf}
Syntax Tree
program [0, 0] - [10, 0]
  comment [0, 0] - [0, 19]
  command [2, 0] - [2, 20]
    name: command_name [2, 0] - [2, 1]
      word [2, 0] - [2, 1]
    argument: expansion [2, 2] - [2, 20]
      variable_name [2, 4] - [2, 8]
      concatenation [2, 10] - [2, 19]
        variable_name [2, 10] - [2, 14]
        word [2, 14] - [2, 19]
  command [3, 0] - [3, 15]
    name: command_name [3, 0] - [3, 1]
      word [3, 0] - [3, 1]
    argument: expansion [3, 2] - [3, 15]
      variable_name [3, 4] - [3, 8]
      word [3, 10] - [3, 14]
  variable_assignment [4, 0] - [4, 23]
    name: variable_name [4, 0] - [4, 4]
    value: expansion [4, 5] - [4, 23]
      variable_name [4, 7] - [4, 11]
      concatenation [4, 13] - [4, 22]
        variable_name [4, 13] - [4, 17]
        word [4, 17] - [4, 22]
  command [5, 0] - [5, 20]
    name: command_name [5, 0] - [5, 1]
      word [5, 0] - [5, 1]
    argument: expansion [5, 2] - [5, 20]
      variable_name [5, 4] - [5, 8]
      concatenation [5, 10] - [5, 19]
        variable_name [5, 10] - [5, 14]
        word [5, 14] - [5, 19]
  command [6, 0] - [6, 20]
    name: command_name [6, 0] - [6, 1]
      word [6, 0] - [6, 1]
    argument: expansion [6, 2] - [6, 20]
      variable_name [6, 4] - [6, 8]
      concatenation [6, 10] - [6, 19]
        variable_name [6, 10] - [6, 14]
        word [6, 14] - [6, 19]
  command [7, 0] - [7, 20]
    name: command_name [7, 0] - [7, 1]
      word [7, 0] - [7, 1]
    argument: expansion [7, 2] - [7, 20]
      variable_name [7, 4] - [7, 8]
      concatenation [7, 10] - [7, 19]
        variable_name [7, 10] - [7, 14]
        word [7, 14] - [7, 19]
  command [8, 0] - [8, 20]
    name: command_name [8, 0] - [8, 1]
      word [8, 0] - [8, 1]
    argument: expansion [8, 2] - [8, 20]
      variable_name [8, 4] - [8, 8]
      concatenation [8, 10] - [8, 19]
        variable_name [8, 10] - [8, 14]
        word [8, 14] - [8, 19]
  command [9, 0] - [9, 20]
    name: command_name [9, 0] - [9, 1]
      word [9, 0] - [9, 1]
    argument: expansion [9, 2] - [9, 20]
      variable_name [9, 4] - [9, 8]
      concatenation [9, 10] - [9, 19]
        variable_name [9, 10] - [9, 14]
        word [9, 14] - [9, 19]
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

1 participant