OCaml: Implement configuration parser, bind lexer tokens with schema

This commit is contained in:
Juno Takano 2025-05-08 23:10:14 -03:00
commit b0c65f40b1
12 changed files with 187 additions and 41 deletions

View file

@ -14,38 +14,35 @@ Grammar v0.2:
break = "\n"
space = " " | "\t"
Written using the ISO 14977 EBNF Notation <https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf>. In this grammar, `digit` implies `decimal digit`.
Written using the ISO 14977 EBNF Notation.
Spaces between the key and the `=` operator are lexed but meaningless. Spaces between the `=` operator and the first non-space character of the value are lexed and considered as part of the value. Spaces before the key and between the value and the newline are not lexed.
In this grammar, `digit` implies `decimal digit`. Spaces between the key and the `=` operator are lexed but meaningless. Spaces between the `=` operator and the first non-space character of the value are lexed and considered as part of the value. Spaces before the key and between the value and the newline are not lexed.
- Note: non-terminals `key` and `value` are ambiguous.
- Resolved by specifying what character terminates each
See also:
## Task list
- Comparison of BNF notations: <https://www.cs.man.ac.uk/~pjj/bnf/ebnf.html>
- W3C ABNF Notation: <https://www.w3.org/Notation.html>
- IETF RFC 5234 ABNF Notation (replaces 4234, 2234): <https://www.rfc-editor.org/rfc/rfc5234>
- [ ] Spec requirements integration test coverage
- [x] Add log function
- [x] Output begins with ` [log] `
- [x] Only prints if `DEBUG` is set
- [ ] Add interactive pkg tests (INS v0 B2.5)
- [ ] Get su command from `$XDG_CONFIG_HOME/tori/tori.conf`
- [ ] Default to `su -c`
- [ ] Validation
- [ ] Valid path or in `PATH`
- [ ] Executability
- ~~`true` exits with status 0 (see note 3)~~
- [x] Add logging
- [x] Logs only if DEBUG is set
- [x] Print each command executed, not just package names
- [x] Case with no packages provided
- [x] Prints a message
- [x] MUST NOT run any system commands
- [x] Get su command from `$XDG_CONFIG_HOME/tori/tori.conf`
- [ ] Default to `su -c`
- [ ] Handle fatal `Sys_error` if `tori.conf` doesn't exist
- [ ] Handle checking `su -c` default with `which` when `tori.conf` exists but `su_command` is absent in it
- [ ] Properly handle a compose `su_command` such as `su -c` in `System.Package`
- [x] Validation
- [x] Valid path or in `PATH`
- [x] Executability
- ~~`true` exits with status 0 (see note 3)~~
- [x] Add logging
- [x] Logs only if DEBUG is set
- [x] Print each command executed, not just package names
- [x] Case with no packages provided
- [x] Prints a message
- [x] MUST NOT run any system commands
- [x] Unrecognized command: exit code 1
- [x] Command `user`: print the output of `whoami`
- [x] Command `os`: print the OS name
@ -56,7 +53,7 @@ See also:
- [ ] Simplify Reader
- [ ] Additionals
- [ ] Create interface files
- [ ] Create remaining interface files
- [ ] Expand unit tests coverage
- [ ] Try out doc generation
@ -79,3 +76,9 @@ See also:
without user input
3. As per item 3 above, INS v0.2 drops "run 'true' with exit code 0" from A3.4
## References
- ISO 14977 EBNF Notation: <https://www.cl.cam.ac.uk/~mgk25/iso-14977.pdf>
- Comparison of BNF notations: <https://www.cs.man.ac.uk/~pjj/bnf/ebnf.html>
- W3C ABNF Notation: <https://www.w3.org/Notation.html>
- IETF RFC 5234 ABNF Notation (replaces 4234, 2234): <https://www.rfc-editor.org/rfc/rfc5234>