[Support Request] Can key names start with a number in the configuration?|字段键名是明确要求不得以数字开头的吗?
- Dominant language
- Go
- Stars
- 6.2k
- Forks
- 402
- Avg merge
- 1h 8m
- Merged PRs (30d)
- 1
Description
### Checks
- [x] I have searched the existing issues
- [x] I have read the documentation
- [x] Is it your first time sumbitting an issue
### Support Request
I'm trying to configure the `dns{upstream{}}` block in my dae config and wanted to use keys that start with "114". Here's the configuration I tried:
```
dns {
upstream {
114_NoPorn_1: 'tcp+udp://114.114.114.110:53'
114_NoPorn_2: 'tcp+udp://114.114.115.110:53'
114_NoMalware_1: 'tcp+udp://114.114.114.119:53'
114_NoMalware_2: 'tcp+udp://114.114.115.119:53'
114_1: 'tcp+udp://114.114.114.114:53'
114_2: 'tcp+udp://114.114.115.115:53'
}
}
```
However, when I run syntax validation, I get errors like:
```
line 196:20 114_NoPorn_1: 'tcp+udp://114.114.114.110:53
^: mismatched input ':' expecting '}'
```
Or:
```
line 3:20 114_NoPorn_1: 'tcp+udp://114.114.114.110:53
^: no viable alternative at input 'dns{upstream{114_NoPorn_1:'
```
I checked the ANTLR grammar definition in [dae_config.g4](https://quantil.jsdelivr.net/gh/daeuniverse/dae-config-dist@main/dae_config.g4), which seems to define two types of elements: `ID` (cannot start with a number) and `NON_ID` (can start with a number). However, I’m not entirely sure how `NON_ID` is used in this context.
---
我尝试在 `dns{upstream{}}` 块中添加以 114 为开头的键名,如:
```
dns {
upstream {
114_NoPorn_1: 'tcp+udp://114.114.114.110:53'
114_NoPorn_2: 'tcp+udp://114.114.115.110:53'
114_NoMalware_1: 'tcp+udp://114.114.114.119:53'
114_NoMalware_2: 'tcp+udp://114.114.115.119:53'
114_1: 'tcp+udp://114.114.114.114:53'
114_2: 'tcp+udp://114.114.115.115:53'
}
}
```
语法验证报:
```
line 196:20 114_NoPorn_1: 'tcp+udp://114.114.114.110:53
^: mismatched input ':' expecting '}'
```
或:
```
line 3:20 114_NoPorn_1: 'tcp+udp://114.114.114.110:53
^: no viable alternative at input 'dns{upstream{114_NoPorn_1:'
```
查 ANTLR 语法定义 [dae_config.g4](https://quantil.jsdelivr.net/gh/daeuniverse/dae-config-dist@main/dae_config.g4) ,似有区分不得以数字开头的 `ID` 和可以数字开头的 `NON_ID` 两类元素,但暂还不太理解 `NON_ID` 是如何运用的。
### Current Behavior
As long as the key name doesn't start with a number, adding any a-z/A-Z/_ characters before it can avoid syntax issues.
---
只要键名不以数字为开头,在前面添加任意 a-z/A-Z/_ 字符就可以规避语法问题。
### Expected Behavior
_No response_
### Steps to Reproduce
Just take a key name starting with a number in the'dns {upstream {}} 'block.
---
在 `dns{upstream{}}` 块中取一个以数字为开头的键名即可。
### Environment
- **Dae version (use `dae --version`)**: v1.0.0rc3
- **OS (e.g `cat /etc/os-release`)**: iStoreOS 24.10.0-20250430
- **Kernel (e.g. `uname -a`)**: Linux iStoreOS 6.6.73 #0 SMP Wed Apr 30 03:39:59 2025 aarch64 GNU/Linux
- **Others**: NA
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked dae_config.g4 grammar and the dns { upstream {} } syntax-validation path, comparing how ID and NON_ID are handled for keys beginning with 114. Confirm whether numeric-leading keys are intended to be supported and make the resulting parser behavior or configuration guidance clear.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100