keymanapp / keymanapp/keyman

feat(developer): Allow having `nul` in a `store` & still output `nul` with `context`

Open
#13,471 7 comments 0 reactions 0 assignees View on GitHub
developer/ feat m:kmn
Dominant language
Pascal
Stars
534
Forks
143
Avg merge
2d 10h
Merged PRs (30d)
113

Description

### Is your feature request related to a problem? Please describe.

Indeed, when writing this snippet in a .kmn file:

```
store(Start) nul ' '

any(Start) 'لَ' ' ' > context(1) 'لا '
```

there are 2 probabilities that this rule holds:
1. with ' ' (space): I type (space) + ل + َ + (space), & successfully get the output: لا
2. with `nul` (empty context buffer): I type nul (start of line .. etc) + ل + َ + (space), & don't get any output

This is most likely due to [this bug](https://github.com/keymanapp/keyman/issues/13276) #13276 that was already solved & now doesn't allow `nul` in context statements, which gives the new [KM020B2](https://help.keyman.com/developer/latest-version/reference/messages/km020b2) error when compiling

**Note**: I am using a version of keyman developer where the #13276 issue has been resolved (18.0.210_beta)

the thing is the `nul` statement in the input is now counted in all platforms of keyman (Windows, Web ... etc), but doesn't allow the user to reference it using a `context(n)` statement in the output

### Describe the solution you'd like

I want the compiler to handle the `nul` statement in this way:
1. Keep counting it as a statement when counting for a `context(n)` output statement
2. Produce a `warn` warning in the console when compiling its containing file when the [KM020B2](https://help.keyman.com/developer/latest-version/reference/messages/km020b2) error appears, (warning instead of an error)
3. When `nul` is directly referenced in a `context(n)` output statement, It just outputs nothing.
4. When a `nul` is referenced in a `context(n)` output statement within a `store` that contains it ( [2nd probability](https://github.com/keymanapp/keyman/issues/13471#:~:text=with%20nul%20,get%20any%20output) ), It still outputs nothing, but its containing rule still **functions**.

Basically, I want to be able to store a `nul` in a `store` & still have the rule that has its `store` **WORK** when `nul` is mentioned (when context buffer is empty)

## Why ?
Because complex Keyman keyboards often have a lot of rules that include statements for the start of words, either with a `nul` or with a (space), this feature will reduce the number of lines required by these rules by half, for example
```
nul 'لَ' any(WordEnding) > 'لا' context(3)
' لَ' any(WordEnding) > ' لا' context(4)
nul any(harf) 'لَ' any(WordEnding) > context(2) 'لا' context(5)
' ' any(harf) 'لَ' any(WordEnding) > ' ' context(2) 'لا' context(5)
nul any(harf) any(diacritic) 'لَ' any(WordEnding) > context(2) context(3) 'لا' context(6)
' ' any(harf) any(diacritic) 'لَ' any(WordEnding) > ' ' context(2) context(3) 'لا' context(6)
```
Will simply become:
```
store(Start) nul ' '
any(Start) 'لَ' any(WordEnding) > 'لا' context(3)
any(Start) any(harf) 'لَ' any(WordEnding) > context(2) 'لا' context(5)
any(Start) any(harf) any(diacritic) 'لَ' any(WordEnding) > context(2) context(3) 'لا' context(6)
```

### Related issues

#13276

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.