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

@ -9,9 +9,14 @@ type output = { main : string; log : string }
type os = Unknown | FreeBSD | Void | Alpine
type host = { os : os; name : string }
type schema = { meta : meta; output : output; host : host }
type configuration_key = SuCommand | Unknown
type main = { su_command : string; }
type configuration = { main : main; }
type input = { configuration: configuration; }
let seed : schema = {
type schema = { meta : meta; output : output; input : input; host : host }
let origin : schema = {
meta = {
version = {
major = 0;
@ -24,6 +29,13 @@ let seed : schema = {
};
status = 0;
};
input = {
configuration = {
main = {
su_command = "su -c"
};
};
};
output = {
(* could be lists of strings or lists of a dedicated type with message,
log level, time and origin in code (e.g. module and function) *)
@ -40,3 +52,8 @@ let format_version (version : version) : string =
"v" ^ str_int version.major ^
"." ^ str_int version.minor ^
"." ^ str_int version.patch
let string_of_key key =
match key with
| SuCommand -> "su_command"
| Unknown -> "<unknown key>"