amber-lang / amber-lang/amber

Support for regex and `=~` operator

未关闭
#250 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
compiler
主要语言
Rust
星标
5.2k
派生
145
平均合并
5 天 3 小时
30 天内合并 PR
7

描述

Bash example:

```bash
line=" aaaaaab"

pattern="[[:space:]]*(a)?b"

if [[ $line =~ $pattern ]]; then
echo "Matches"
fi
```

Source: https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Conditional-Constructs

Is there a way or plan to implement this with Amber?

The following code:

```amber
main (args) {
let line = " aaaaaab"

let pattern = "[[:space:]]*(a)?b"

if line =~ pattern {
echo "Matches"
}
}
```

Does not compile:

```stdout
ERROR
Identifier 'if' is a reserved keyword
at example.ab:6:3

5|
6| if text =~ pattern {
7| echo "Matches"
```

Using Amber 0.3.3-alpha

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。