summaryrefslogtreecommitdiff
path: root/tools/Scanner/Protocol.lean
diff options
context:
space:
mode:
Diffstat (limited to 'tools/Scanner/Protocol.lean')
-rw-r--r--tools/Scanner/Protocol.lean27
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