diff options
| author | Hannes Schulze <haschu0103@outlook.de> | 2026-04-05 16:15:03 +0200 |
|---|---|---|
| committer | Hannes Schulze <haschu0103@outlook.de> | 2026-04-05 16:15:03 +0200 |
| commit | 1f5491a5af7bd0f1ec4046994d6344886465cba5 (patch) | |
| tree | 9ca3af2221cdbc302b932b67965791a8065699a9 /tools/Scanner/Protocol.lean | |
| parent | ad4d34bba7671fdf75850a312c7eeeaeb990a9d3 (diff) | |
initial codegen
Diffstat (limited to 'tools/Scanner/Protocol.lean')
| -rw-r--r-- | tools/Scanner/Protocol.lean | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/Scanner/Protocol.lean b/tools/Scanner/Protocol.lean index 77908d9..6f74126 100644 --- a/tools/Scanner/Protocol.lean +++ b/tools/Scanner/Protocol.lean @@ -15,6 +15,32 @@ def Description.ofSummary (s : String) : Description := def Identifier := String deriving Repr, BEq, Ord, Inhabited +def Identifier.quoted (ident : Identifier) : String := + let s : String := ident + s!"\"{s}\"" + +private def Identifier.pascalCase' (parts : List String.Slice) : String := + parts + |>.map (String.capitalize ∘ String.Slice.toString) + |> String.join + +private def sanitize (s : String) : String := + let isInvalid := + ((0 : String.Pos.Raw).get s).isDigit || s == "class" + if isInvalid then "_" ++ s else s + +def Identifier.pascalCase (ident : Identifier) : String := + ident + |>.split "_" + |>.toList + |> pascalCase' + |> sanitize + +def Identifier.camelCase (ident : Identifier) : String := + match (ident.split "_").toList with + | [] => "" + | x::xs => sanitize (x.toString ++ pascalCase' xs) + namespace Raw structure EnumEntryDesc where @@ -145,6 +171,7 @@ structure MessageDesc where since : Nat deprecatedSince : Option Nat arguments : Array ArgumentDesc + rawArguments : Array Raw.ArgumentDesc deriving Repr, BEq, Inhabited inductive ReturnType where |
