Commit graph

7 commits

Author SHA1 Message Date
AnotherTest
1a4ac3531f Shell: Allow parts of globs to be named in match expressions
This patchset allows a match expression to have a list of names for its
glob parts, which are assigned to the matched values in the body of the
match.
For example,
```sh
stuff=foobarblahblah/target_{1..30}
for $stuff {
    match $it {
        */* as (dir sub) {
            echo "doing things with $sub in $dir"
            make -C $dir $sub # or whatever...
        }
    }
}
```

With this, match expressions are now significantly more powerful!
2020-10-29 11:53:01 +01:00
AnotherTest
5640e1bc3a Shell: Add support for brace expansions
This adds support for (basic) brace expansions with the following
syntaxes:
- `{expr?,expr?,expr?,...}` which is directly equivalent to `(expr expr
  expr ...)`, with the missing expressions replaced with an empty string
  literal.
- `{expr..expr}` which is a new range expansion, with two modes:
    - if both expressions are one unicode code point long, the range is
      equivalent to the two code points and all code points between the
      two (numerically).
    - if both expressions are numeric, the range is equivalent to both
      numbers, and all numbers between the two.
    - otherwise, it is equivalent to `(expr expr)`.

Closes #3832.
2020-10-25 10:09:27 +01:00
AnotherTest
b1b202124c Shell: Use Node::kind() instead of Node::class_name() in formatter 2020-10-14 21:05:39 +02:00
AnotherTest
738f512919 Shell: Respect input sources' blank lines between sequences
But collapse them to a single empty line.
This makes the generated sources look significantly better.
2020-10-14 21:05:39 +02:00
AnotherTest
cd48ec2abd Shell: Put a space after the match pattern expression when formatting 2020-10-14 21:05:39 +02:00
AnotherTest
f164b808b5 Shell: Move everything to the Shell namespace
Also provide a basic default-constructor.
2020-10-04 23:12:28 +02:00
AnotherTest
b3dd97a694 Shell: Add a (very basic) formatter 2020-09-26 21:28:35 +02:00